The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » Merging IR and KR with PR - no unique identifiers (for particular countries only)
Re: Merging IR and KR with PR - no unique identifiers (for particular countries only) [message #14978 is a reply to message #14974] Wed, 23 May 2018 07:53 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 Stata Specialist, Tom Pullum:

Regarding what's in what file--you may have found some exceptions to the general pattern. Also there have been some changes over time; what's standard now has not always been standard.

Yes, there are some surveys with files that are difficult to merge. If you don't have b16, then you can't merge the KR and PR files with complete reliability, but apart from that some merges are difficult.

Try the following example of a PR / KR merge, which uses caseid and hhid. (You will want to include more variables in the "keep" lines and change the paths.) It should work on some of those difficult merges but probably not all. Let me know which ones remain.

I want DHS to prepare a library of merge programs for these difficult cases. The basic problem is that in some surveys there is a sub-household id and it's not well documented.

use "C:\Users\2626I\ICF\Analysis - Shared Resources\Data\DHSdata\PEKR6IFL.DTA" , clear
gen hhid=substr(caseid,1,12)
rename b16 hvidx
gen in_KR=1
keep hhid hvidx in*
sort hhid hvidx
save e:\DHS\DHS_data\scratch\PEKR6Itemp.dta, replace

use "C:\Users\2626I\ICF\Analysis - Shared Resources\Data\DHSdata\PEPR6IFL.DTA" , clear
gen in_PR=1
keep hhid hvidx in*
sort hhid hvidx
merge hhid hvidx using e:\DHS\DHS_data\scratch\PEKR6Itemp.dta
tab _merge
 
Read Message
Read Message
Read Message
Previous Topic: Generating ID variable
Next Topic: Nigeria 2003 merging datasets
Goto Forum:
  


Current Time: Sun Dec 1 15:41:15 Coordinated Universal Time 2024