Merging CR and PR file [message #19322] |
Fri, 29 May 2020 23:16 |
nagar002
Messages: 9 Registered: April 2018
|
Member |
|
|
Hi DHS users,
I am looking for some help about merging the CR file with the PR file (need to bring husband's anemia from the PR file to the CR file). I have written the following code and I'll appreciate if someone can provide feedback about the correct way to do this. I couldn't find any post about the link of CR and PR file.
And are the duplicates in line three of the code below due to one man married to more than one female?
use "IACR74FL.DTA", clear
sort v001 v002 v034
quietly by v001 v002 v034: gen dup = cond(_N==1,0,_n) //why are there duplicates here?
drop if dup>0
tempfile cr
save `cr', replace
use "IAPR74FL.DTA", clear
ren hv001 v001
ren hv002 v002
clonevar v034=hvidx
sort v001 v002 v034
keep v001 v002 v034 hb57
merge 1:1 v001 v002 v034 using `cr'
keep if _m==3
<This example is for India. I have more countries in my sample, but I believe the basic idea can be used as it is for other surveys.>
In essence, my question is can we use v034 (the variable that identifies the husband in CR file) to bring information from the PR file about the husband?
Thanks you for any help.
[Updated on: Fri, 29 May 2020 23:18] Report message to a moderator
|
|
|