The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » STATA codes to merge women and household datasets
Re: STATA codes to merge women and household datasets [message #18063 is a reply to message #18042] Tue, 03 September 2019 15:37 Go to previous messageGo to previous message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3046
Registered: February 2013
Senior Member
Following is a response from DHS Research & Data Analysis Director, Tom Pullum:

Hi Isabelle--Here is how I would do the merge. I use the old version of the merge command but you would get the same thing if you used 1:1. I also introduce a variable called "in_IR", which is coded 1 for every case in the IR file. It just clarifies the "_merge" code, which is described in your results with different terms.

ALL of the 90,303 cases in the IR file are also in the PR file. 427,076 people in the PR file are NOT also in the IR file. Hope this makes sense. Tom


cd e:\DHS\DHS_data\scratch

use "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\IAIR42FL.DTA" , clear
gen hv024=v024
gen hv001=v001
gen hv002=v002
gen hvidx=v003
gen in_IR=1
sort hv024 hv001 hv002 hvidx
save IAIR42_temp.dta, replace

use "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\IAPR42FL.DTA" , clear
sort hv024 hv001 hv002 hvidx
merge hv024 hv001 hv002 hvidx using IAIR42_temp.dta
replace in_IR=0 if in_IR==.
tab _merge
tab _merge in_IR

The following table is produced:

/index.php?t=getfile&id=1465&private=0
  • Attachment: table.PNG
    (Size: 11.14KB, Downloaded 3597 times)
 
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: SPA 2012-2017 Senegal
Next Topic: sample weights in women file
Goto Forum:
  


Current Time: Tue Apr 30 16:39:04 Coordinated Universal Time 2024