The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Dataset use in Stata » merging wealth index from Ethiopia DHS 2000 to women's file
Re: merging wealth index from Ethiopia DHS 2000 to women's file [message #13321 is a reply to message #13319] Wed, 18 October 2017 08:34 Go to previous messageGo to previous message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3202
Registered: February 2013
Senior Member
Another response from one of our STATA experts, Tom Pullum:

If you look at hhid in BFWI31FL.dta and compare it with caseid in BFBR31FL.dta, you will see that hhid matches the first 12 (out of 15) characters in caseid. (The last 3 characters in caseid are a blank and the mother's line number). The following lines will do the merge if you change the paths to the data files. I am using an old version of the merge command, which I prefer.

use e:\DHS\DHS_data\BR_files\BFBR31FL.dta, clear
gen hhid=substr(caseid,1,12)
sort hhid
save e:\DHS\DHS_data\scratch\temp.dta, replace

use e:\DHS\DHS_data\WI_files\BFWI31FL.dta, clear
rename whhid hhid
sort hhid
merge hhid using e:\DHS\DHS_data\scratch\temp.dta
tab _merge
keep if _merge==3
drop _merge
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Hypertension in Nepal
Next Topic: Keeping caseid in and keeping missing observations out when using Stata "collapse"
Goto Forum:
  


Current Time: Mon Dec 2 16:05:56 Coordinated Universal Time 2024