Announcement

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

  • Creating a dyadic/triadic data set and running into issues merging

    Hello,
    I am creating a long data set with siblings. I have one data set named siblings that has variables id, sib_id1, sib_rel1, sib_id2, sib_rel2, sib_id3, sib_rel3. I have renamed these variables aid1 aid2 aid3 aid4 and the same for the sibling relationship. In order to merge this data with my actual variables what I have done is the following.
    First I created data sets with new titles for each aid merge.


    Code:
    use "Z:dataset.dta" 
    rename aid aid1
    rename age age1
    rename race racevar1
    save "Z:datasetaid1.dta"
    clear
    
    use "Z:dataset.dta" 
    rename aid aid2
    rename age age2
    rename race racevar2
    save "Z:datasetaid2.dta"
    clear
    
     
    use "Z:dataset.dta" 
    rename aid aid3
    rename age age3
    rename race racevar3
    save "Z:datasetaid1.dta"
    clear
    
    use "Z:dataset.dta" 
    rename aid4 aid4
    rename age age4
    rename race racevar4
    save "Z:datasetaid4.dta"
    clear
    My problems lies when I merge the data sets. I use the joinby function and the following code. Despite my aid1 and aid2 having the same sample size and the same id numbers in different order I am unable to merge the same amount of age and race and other variables. Below is the code I am using.

    Code:
     
    clear
    use "Z:siblingw"
    joinby aid1 using "Z:datasetaid1.dta"
    save "Z:joinaid1.dta"
    clear
    
    use  "Z:joinaid1.dta"
    joinby aid2 using "Z:datasetaid2.dta"
    What could be causing my descriptive variables such as age to be less when aid1 and aid2 have the same ids but in different order? For example my age variable has an N of 4000 for age1 then an N of 3700 for age2.



Working...
X