The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » Merging DHS data in Stata
Re: Merging DHS data in Stata [message #11165 is a reply to message #11129] Fri, 11 November 2016 10:27 Go to previous messageGo to previous message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3214
Registered: February 2013
Senior Member
Following is a response from Senior DHS Stata Specialist, Tom Pullum:

Quote:
You are using SPSS and I only work with Stata, so I cannot give you SPSS code. In Stata correct steps would be as follows. You want to merge on the household id code, which is whhid in the WI file and is the first 12 characters of caseid in the IR file. I hope than in SPSS you know a way to extract the first 12 characters of caseid.

use e:\DHS\DHS_data\WR_files\PKWR21FL.dta, clear
sort whhid
save e:\DHS\DHS_data\scratch\PKWRtemp.dta, replace

use e:\DHS\DHS_data\IR_files\PKIR21FL.dta, clear
gen whhid=substr(caseid,1,12)
sort whhid
merge whhid using e:\DHS\DHS_data\scratch\PKWRtemp.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
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
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: How to match women to their husbands
Next Topic: Merging HR and PR Files
Goto Forum:
  


Current Time: Wed Dec 25 21:42:42 Coordinated Universal Time 2024