The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » Merging DHS Files
Re: Merging DHS Files [message #10093 is a reply to message #10086] Mon, 27 June 2016 07:14 Go 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:

The following lines will do the merge, combining the IR and MR variables with the PR variables. It appears that more information was collected for women than for men, but I leave it to you to deal with that.

set more off
set maxvar 10000

use e:\DHS\DHS_data\IR_files\AZIR52FL.dta, clear
rename v001 hv001
rename v002 hv002
rename v003 hvidx
gen in_IR=1
sort hv001 hv002 hvidx
save e:\DHS\scratch\tempAZIR52.dta, replace

use e:\DHS\DHS_data\MR_files\AZMR52FL.dta, clear
rename mv001 hv001
rename mv002 hv002
rename mv003 hvidx
gen in_MR=1
sort hv001 hv002 hvidx
save e:\DHS\scratch\tempAZMR52.dta, replace

use e:\DHS\DHS_data\PR_files\AZPR52FL.dta, clear
gen in_PR=1
sort hv001 hv002 hvidx
merge hv001 hv002 hvidx using e:\DHS\scratch\tempAZIR52.dta
tab _merge
drop _merge

sort hv001 hv002 hvidx
merge hv001 hv002 hvidx using e:\DHS\scratch\tempAZMR52.dta
tab _merge
drop _merge
keep if in_PR==1 & (in_IR==1 | in_MR==1)
drop in_*
 
Read Message
Read Message
Previous Topic: ID variables for Children
Next Topic: 2014 Kenya DHS merging household and men's datafile
Goto Forum:
  


Current Time: Sun Dec 22 16:14:24 Coordinated Universal Time 2024