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 #9747 is a reply to message #9730] Thu, 12 May 2016 09:08 Go to previous messageGo to previous message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3214
Registered: February 2013
Senior Member
An additional response from Tom Pullum to the post: Quote:
I tried to merge the file of PR and IR, by following.....


The problem is that you have not used the line numbers. The following should work. You do not really need in_IR and in_PR, but since you constructed them, I am keeping them.

use PKPR61FL.DTA, clear
rename hv001 v001
rename hv002 v002
rename hvidx v003
gen in_PR=1
sort v001 v002 v003
save temp.dta
use PKIR61FL.DTA, clear
gen in_IR=1
sort v001 v002 v003
merge v001 v002 v003 using temp.dta
keep if in_PR==1 & in_IR==1
drop _merge in_PR in_IR

[Updated on: Thu, 12 May 2016 09:12]

Report message to a moderator

 
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:27:32 Coordinated Universal Time 2024