The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » Struggling with merging Senegal KR data file to mother's file (Struggling with merging Senegal KR data to mother's info PR + IR)
Struggling with merging Senegal KR data file to mother's file [message #18425] Thu, 28 November 2019 03:02 Go to previous message
petyr is currently offline  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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Mismatch of file names within the same survey
Next Topic: Merge Other Biomarkers with HH
Goto Forum:
  


Current Time: Mon Dec 2 04:44:21 Coordinated Universal Time 2024