Announcement

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

  • Merging 2 observations for the same individual

    In my dataset, there are 2 observations for each individual where they are asked general survey questions and then also take a test where they receive a score. I want to get both scores in the same single observation so I can use the outcome variable as the difference between the 2 scores. Any advice on what code to type would be appreciated. Many thanks

    (attached is a snapshot of the data)

    Click image for larger version

Name:	statalist.png
Views:	1
Size:	137.2 KB
ID:	1689834

  • #2
    Ensure both datasets have an identically named variable to identify the persons (say person_id), then open up any one dataset and type

    Code:
    merge 1:1 person_id using path_to_other_dataset, gen(_mergetype)
    Also, as advised in the Statalist FAQ (see esp. section 12), please do not post screenshots of your data. It is great to have an extract of your data, and this should be posted using the dataex command.
    Last edited by Hemanshu Kumar; 17 Nov 2022, 03:30.

    Comment

    Working...
    X