The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Countries » Kenya » Merging KR and PR files
Re: Merging KR and PR files [message #28016 is a reply to message #28006] Thu, 02 November 2023 08:15 Go to previous messageGo to previous message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3199
Registered: February 2013
Senior Member
Following is a response from Senior DHS staff member, Tom Pullum:

The Stata lines pasted below will do this merge. In the KR file, you have to drop children with b16=. (they have died) or b16=0 (they are not in the household).

* Merge the KR and PR files, Kenya 2022 survey

* Specify workspace
cd e:\DHS\DHS_data\scratch

* Prepare KR file
use "...KEKR8BFL.DTA", clear
gen cluster=v001
gen hh=v002

* b16 is na if the child has died and 0 if the child is not in the hh
drop if b16==. | b16==0
gen line=b16
sort cluster hh line
save KR8BKRtemp.dta, replace

* Prepare PR file and merge
use "...KEPR8BFL.DTA", clear
gen cluster=hv001
gen hh=hv002
gen line=hvidx
sort cluster hh line
merge 1:1 cluster hh line using KR8BKRtemp.dta
tab _merge
keep if _merge==3
drop _merge
 
Read Message
Read Message
Read Message
Previous Topic: Figure 4.4 Trends in early marriage
Next Topic: KDHS 2014 : Table 14.10.1 Health insurance coverage: Women
Goto Forum:
  


Current Time: Sun Dec 1 07:25:46 Coordinated Universal Time 2024