Struggling with merging Senegal KR data file to mother's file [message #18425] |
Thu, 28 November 2019 03:02 |
petyr
Messages: 3 Registered: November 2019
|
Member |
|
|
Hello,
I have been struggling mightily trying to merge the PR, KR and IR data sets for the 2012-2014 Senegal dataset. I have looked into the different ideas proposed in the forum as well as watched the YouTube videos but I continue to be unsuccessful. In the end, I want to be sure that I have successfully linked all of the kids to their mothers. I am using the numbers and % of children in the 2014 report with fever 2 weeks prior as a check against my work.
The report indicates a rate of 11.4% among 5942 (6,842 unweighted observations in KR). Meanwhile, I am finding 6,223 unweighted observations and ending up with a rate of 11.9% among 6,239.
I am not sure why I am missing kids info during the merge.
Below is the code that I have come up so far. Any help with troubleshooting to replicate DHS results would greatly appreciated.
Thank you
***********************
set more off
clear
****Prepare KR for merge
use "SNKR6RFL.DTA", clear
count
gen hvidx=b16
gen in_KR=1
sort v001 v002 hvidx
save "KRtemp14.dta", replace
****Prepare IR for merge
use "SNIR6RFL.DTA", clear
rename v003 hvidx
gen mo_line=hvidx
sort v001 v002 mo_line
drop h22*
save "IRtemp14.dta", replace
****Prepare PR for merge
use "SNPR6RFL.DTA", clear
gen v001=hv001
gen v002=hv002
gen in_PR=1
sort v001 v002 hvidx
* Merge PR with KR to identify the children who are living with their mother
quietly merge m:m v001 v002 hvidx using "KRtemp14.dta"
rename _merge _merge_PR_KR
tab1 in_*,m
drop if in_PR==.
gen in_PR_BR=1
gen mo_line=hv112
*Use the IR file to attach information about the child's mother
sort v001 v002 mo_line
quietly merge m:m v001 v002 mo_line using "IRtemp14.dta"
rename _merge _merge_PR_BR_IR
tab1 in_*,m
keep if in_PR==1
keep hhid hvidx hv000 hv001 hv002 hv003 hv004 hv005 hv006 hv007 hv008 hv021 hv022 ///
hv023 hv024 hv042 hv103 hml1 hc1 h22 hc55 hc56 hml1a hml2 b5 h32* h46b h47 ///
shzone shmzone shseason shml1a sh221aa sh221ab sh221ac sh221ad sh221ae sh221af sh221ag ///
sh221ah sh221ay sh225a sh231a hml16 hml16a hml30 hml32 hml33 hml35 ml13* v005 v007 v021 v024
save "IR_KR_PR_merge2012_2014.dta", replace
|
|
|
|
|
|
|
|
Re: Struggling with merging Senegal KR data file to mother's file [message #24305 is a reply to message #24243] |
Fri, 15 April 2022 16:02 |
admin
Messages: 50 Registered: November 2012
|
Senior Member Administrator |
|
|
Following is response from DHS Research & Data Analysis Director, Tom Pullum:
The PR file includes all household members. The IR file includes women who were eligible for the women's interview, in terms of age and de facto residency. Some women who are eligible for the IR file do not actually get into it because (for one reason or another) the interview does not happen. The KR file includes children born in the past 5 years to women in the IR file. It includes children who died and some children who live elsewhere, so they are not in the PR file.
For these reasons, you cannot get an exact match between the PR file and the KR file, either for the children or for the mothers. You definitely will not find "elderly" in the KR file, because the mothers must be in the age range 15-49. Mothers in the KR file are repeated for each child.
If this does not answer your question, please be more specific about which data files you are using and which cases or variables you want to match.
We now have repositories of code written in Stata and SPSS available on Github. Please reference these code repositories as a resource for code for matching or calculating DHS indicators. The code repositories can be found at:
https://github.com/DHSProgram/DHS-Indicators-Stata
https://github.com/DHSProgram/DHS-Indicators-SPSS
|
|
|