The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » Issue merging NFHS 2 women and household dataset
Re: Issue merging NFHS 2 women and household dataset [message #13965 is a reply to message #13962] Tue, 30 January 2018 08:42 Go to previous messageGo to previous message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3199
Registered: February 2013
Senior Member
Another response from Tom Pullum:

You should not use the HR file for this merge. The HR file has one record for each household. Instead, use the PR file, which has one record for every person in the household. The following lines will do the merge. In the output file, the cases with _merge=3 are the women in the IR file. The cases with _merge=1 are the other people in the PR file, that is, the household members other than the women in the IR file.

set more off
* Prepare IR file for merge
use e:\DHS\DHS_data\IR_files\IAIR42FL.dta, clear 
gen hv001=v001
gen hv002=v002
gen hvidx=v003
sort hv001 hv002 hvidx
save e:\DHS\DHS_data\scratch\IAIRtemp.dta, replace


* Prepare PR file for merge
use e:\DHS\DHS_data\PR_files\IAPR42FL.dta, clear
sort hv001 hv002 hvidx

* Merge IR with PR
merge hv001 hv002 hvidx using  e:\DHS\DHS_data\scratch\IAIRtemp.dta
tab _merge

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Appending Indonesian DHS 2007 and 2012
Next Topic: merging variables from HR to BR
Goto Forum:
  


Current Time: Thu Nov 28 18:58:42 Coordinated Universal Time 2024