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 #8388 is a reply to message #8347] Wed, 21 October 2015 13:55 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:

I can do everything I want with the old version of merge, which did not include 1:1 or 1:m or m:1 or m:m. I prefer simplicity, so I stay with the old version, but it's not better or worse. You can use whatever version of the merge command that you want to.

You should only occasionally need to use joinby. It's a very powerful command but tends to produce files that are much much larger than the input files. It will give you all possible combinations of cases that match on whatever id code you are using. If you have 10 cases in file 1 with id=12345 and 8 cases in file 2 with id=12345, you will get 10*8 joined (or paired) cases with id=12345.

I think what you want to do would be as follows:

use PRXXXXFL.dta, clear
rename hv001 v001
rename hv002 v002
rename hvidx v003
sort v001 v002 v003
save temp.dta, replace

use IRXXXXFL.dta, clear
sort v001 v002 v003

merge v001 v002 v003 using 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
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:59:40 Coordinated Universal Time 2024