Hello ,
I had posted this question and the variable description here.
https://www.statalist.org/forums/for...-year-matching
I thought I might explain the difficulty I face a bit more clearly, so Im posting again.
I created unique IDs for the mother and father (ID_mil ID_fil) . The index observation in this dataset (Dataset 1) is the eligible women, but I want to have a variable next to each PERSONID that shows the years since their parents passed.
(Dataset 1)
[CODE]. dataex ID_PERSON STATEID DISTID PSUID HHID2005 HHSPLITID2005 PERSONID PID2005 SPRO10 SPRO9 ID_mil ID_fil
----------------------- copy starting from the next line -----------------------
------------------ copy up to and including the previous line ------------------
I have Dataset 2 that has the expiry information of all the individuals interviewed in wave 1.
I merged using this command
I couldn't use PID2005 to merge as I got the message STATEID DISTID PSUID HHID2005 HHSPLITID2005 PID2005 wasn't uniquely identifying observations in using data.
But merging will show the years since death (TH3) of the index case which is the eligible women not her parents like I need.
So how can I run the code such that a column comes up next to the PERSONID or PID2005 which shows TH3 (or any newly created variable years since the passing away of the parent (fil mil))
I had posted this question and the variable description here.
https://www.statalist.org/forums/for...-year-matching
I thought I might explain the difficulty I face a bit more clearly, so Im posting again.
I created unique IDs for the mother and father (ID_mil ID_fil) . The index observation in this dataset (Dataset 1) is the eligible women, but I want to have a variable next to each PERSONID that shows the years since their parents passed.
(Dataset 1)
[CODE]. dataex ID_PERSON STATEID DISTID PSUID HHID2005 HHSPLITID2005 PERSONID PID2005 SPRO10 SPRO9 ID_mil ID_fil
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double ID_PERSON int(STATEID DISTID PSUID) float(HHID2005 HHSPLITID2005 PERSONID) int(PID2005 SPRO10 SPRO9) double(ID_mil ID_fil) 10201002009 1 2 1 2 0 9 9 2 1 102012002 102012001 10201016004 1 2 1 16 0 4 4 2 1 1020116002 1020116001 10201018005 1 2 1 18 0 5 5 2 1 1020118002 1020118001 10201030102 1 2 1 3 0 2 2 75 69 1020130175 1020130169 10201050102 1 2 1 5 0 2 3 75 75 1020150175 1020150175 10201160104 1 2 1 16 0 4 4 2 1 10201160102 10201160101 10201170102 1 2 1 17 0 2 1 75 75 10201170175 10201170175 10201180105 1 2 1 18 0 5 5 11 75 10201180111 10201180175 10201200104 1 2 1 20 0 4 4 2 1 10201200102 10201200101 10202006004 1 2 2 6 0 4 4 2 1 102026002 102026001 10202007004 1 2 2 7 0 4 4 2 1 102027002 102027001 10202014002 1 2 2 14 0 2 2 6 75 1020214006 1020214075 10202015002 1 2 2 15 0 2 2 7 6 1020215007 1020215006 10202017002 1 2 2 17 0 2 2 7 75 1020217007 1020217075 10202040102 1 2 2 4 0 2 2 75 75 1020240175 1020240175 10202060102 1 2 2 6 0 2 4 9 75 1020260109 1020260175 10202070104 1 2 2 7 0 4 4 2 1 1020270102 1020270101 10202150102 1 2 2 15 0 2 2 7 75 10202150107 10202150175 10202160102 1 2 2 16 0 2 2 75 75 10202160175 10202160175 10202170102 1 2 2 17 0 2 2 75 75 10202170175 10202170175 10202200102 1 2 2 20 0 2 2 75 75 10202200175 10202200175 10203006009 1 2 3 6 0 9 9 2 1 102036002 102036001 10203011002 1 2 3 11 0 2 2 6 75 1020311006 1020311075 10203014004 1 2 3 14 0 4 4 2 1 1020314002 1020314001 10203015003 1 2 3 15 0 3 3 6 . 1020315006 10203150 end label values STATEID STATEID label def STATEID 1 "Jammu & Kashmir 01", modify label values SPRO10 SPRO10 label def SPRO10 75 "Died 75", modify label values SPRO9 SPRO9 label def SPRO9 69 "Other nonres 69", modify label def SPRO9 75 "Died 75", modify
I have Dataset 2 that has the expiry information of all the individuals interviewed in wave 1.
Code:
. dataex STATEID DISTID PSUID HHID2005 HHSPLITID2005 TK1 PERSONID TH1 TH3 PID2005 ----------------------- copy starting from the next line -----------------------Code:* Example generated by -dataex-. To install: ssc install dataex clear input int(STATEID DISTID PSUID) float(HHID2005 HHSPLITID2005) int(TK1 PERSONID TH1 TH3 PID2005) 1 2 1 5 0 1 1 1 4 1 1 2 1 6 0 10 10 10 1 10 1 2 1 9 0 1 1 1 4 1 1 2 1 18 0 1 1 1 1 1 1 2 2 5 0 1 1 1 4 1 1 2 2 6 0 1 1 1 3 1 1 2 2 12 0 1 1 1 2 1 1 2 2 14 0 6 6 6 4 6 1 2 2 15 0 6 6 6 6 6 1 2 2 17 0 7 7 7 3 7 1 2 3 4 0 2 2 2 4 2 1 2 3 8 0 1 1 1 5 1 1 2 3 8 0 2 2 2 4 2 1 2 3 8 0 6 6 6 1 6 1 2 3 13 0 1 1 1 6 1 1 2 3 13 0 2 2 2 6 2 1 2 3 19 0 1 1 1 4 1 1 2 3 19 0 2 2 2 5 2 1 2 3 20 0 1 1 1 6 1 1 2 4 2 0 2 2 2 3 2 1 2 4 11 0 1 1 1 5 1 1 2 4 11 0 2 2 2 3 2 1 2 4 13 0 1 1 1 5 1 1 2 4 14 0 1 1 1 6 1 1 2 4 17 0 2 2 2 5 2 1 2 5 1 0 6 6 6 2 6 1 2 5 3 0 3 3 3 4 3 1 2 5 4 0 9 9 9 2 9 1 2 5 5 0 9 9 9 3 9 1 2 5 8 0 1 1 1 3 1 1 2 5 10 0 2 2 2 2 2 1 2 6 3 0 10 10 10 1 10 1 2 7 5 0 28 28 28 5 28 1 2 7 10 0 6 6 6 4 6 1 2 7 12 0 7 7 7 7 7 1 3 1 8 0 2 2 2 3 2 1 3 1 12 0 1 1 1 2 1 end label values STATEID STATEID label def STATEID 1 "Jammu & Kashmir 01", modify
Code:
use Dataset1 merge m:1 STATEID DISTID PSUID HHID2005 HHSPLITID2005 PERSONID using Dataset2
But merging will show the years since death (TH3) of the index case which is the eligible women not her parents like I need.
So how can I run the code such that a column comes up next to the PERSONID or PID2005 which shows TH3 (or any newly created variable years since the passing away of the parent (fil mil))
Comment