Re: Merging KR with PR [message #25450 is a reply to message #25445] |
Fri, 21 October 2022 08:56 |
Bridgette-DHS
Messages: 3216 Registered: February 2013
|
Senior Member |
|
|
Following is a response from DHS staff member, Tom Pullum:
I believe the Stata lines pasted below will do what you want. You did not need to use the line for the child's caretaker. Every member of a household, including every child, has their own unique line number and line of data. In the PR file, hvidx is the line number, and in the KR file, b16 is the line number (for children who are alive and living with the mother). I'm not sure which variables you want, but these lines keep all the hml variables in the PR file and all the ml variables in the KR file. You could include other variables. It appears that there was subsampling for the malaria tests. You may want to modify the "keep" line at the end. Good luck!
* Specify workspace
cd e:\DHS\DHS_data\scratch
* Nigeria 2018
* Combine hml variables in the PR file with the ml variables in the KR file
use "...NGPR7BFL.DTA", clear
keep if hc1<.
rename hv001 cluster
rename hv002 hh
rename hvidx line
keep cluster hh line hml*
sort cluster hh line
save NGPRtemp.dta, replace
use "...NGKR7BFL.DTA", clear
keep if b16>0 & b16<.
rename v001 cluster
rename v002 hh
rename b16 line
keep cluster hh line v0* ml* hw*
sort cluster hh line
merge cluster hh line using NGPRtemp.dta
tab hml32 _merge,m
keep if _merge==5 & hml32<.
drop _merge
[Updated on: Fri, 21 October 2022 08:57] Report message to a moderator
|
|
|