Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Merge or append two datasets

    Dear altruist I have problem, I have two dataset in following format

    Dataset1
    ID Age
    1 17
    2
    3 19
    4
    5
    6

    Dataset2
    ID Age
    1 17
    2 19
    3 19
    4 20
    5 15
    6 16
    Here ID is a unique variable. I have dataset1 now I want to construct dataset2 after inputing corresponding id's value from another dataset. So what should I use merge or append? I have already used merge and append but not come up with the Dataset2 like table. Please help me.
    Last edited by Rayhan Islam; 11 Jun 2017, 03:03.

  • #2
    Rayhan:
    welcome to the list.
    It would seem a job for -merge-.
    What went wrong?
    Kind regards,
    Carlo
    (Stata 18.0 SE)

    Comment


    • #3
      Thanks for your response. But the problem is when I do merge variable of age which was previously blank remain blank after merge.
      Output showed that the data was merged but not shown in merged file "Age" column.

      here is the code and output image.
      [use dataset1, clear
      merge 1:1 UniqueID using "dataset2", force]
      Click image for larger version

Name:	stata output.png
Views:	1
Size:	4.0 KB
ID:	1397285
      Last edited by Rayhan Islam; 12 Jun 2017, 00:56.

      Comment


      • #4
        Rayhan:
        is -Age- numerical in both datasets?
        Kind regards,
        Carlo
        (Stata 18.0 SE)

        Comment


        • #5
          No. Here I used age for example. But in my real dataset Age like variable is RID which is like "4V19053210" so when I use [destring RID, replace] it shows
          "RID contains nonnumeric characters; no replace"
          And my UniqueID also look like RID.
          how can I make do conversion before merge?
          Last edited by Rayhan Islam; 12 Jun 2017, 02:13.

          Comment

          Working...
          X