The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Countries » India » Merged HH and Individual Data
Re: Merged HH and Individual Data [message #16099 is a reply to message #16089] Mon, 05 November 2018 07:27 Go to previous messageGo to previous message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3199
Registered: February 2013
Senior Member
Following is another response from Senior DHS Stata Specialist, Tom Pullum:

You could do something like the following. Before you do the merge, assign the women in the IR file a random number; then sort the women in the household by this number; then keep the one who is first in the sort. Then do the merge with the household file. in the following, I use the HR file rather than the PR file, and just keep the household-level variables.

set more off
set maxvar 10000
use ...IAHR74FL.DTA" , clear
drop *_*
sort hv024 hv001 hv002 
save ...IAHRtemp.dta, replace

use ...IAIR74FL.DTA" , clear
gen rn=uniform()
sort v024 v001 v002 rn
egen sequence=seq(), by(v024 v001 v002)
tab sequence
keep if sequence==1
gen hv024=v024
gen hv001=v001
gen hv002=v002
sort hv024 hv001 hv002
merge hv024 hv001 hv002 using e:\DHS\DHS_data\scratch\IAHRtemp.dta
keep if _merge==3
drop sequence _merge

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Village related questions (NFHS-3, NFHS-4)
Next Topic: Matching Household number to education of household head
Goto Forum:
  


Current Time: Wed Nov 27 18:27:36 Coordinated Universal Time 2024