The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » Merging Men, Women, Child dataset into Household level unit analysis
Re: Merging Men, Women, Child dataset into Household level unit analysis [message #9208 is a reply to message #9199] Tue, 23 February 2016 16:57 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 do not use SPSS. Perhaps you do not use Stata at all, but I will list below the lines to do this in Stata and you may be able to figure out the logic.

First you combine the IR, MR, and KR files by appending, NOT merging. This is very important. Then you merge the combined IR_MR_KR file with the PR file. If you first merge the IR file with the PR file, and then merge the MR file, and then merge the KR file, you will have a mess.

* prepare the IR, MR, and KR files

use IRfile.dta, clear
rename v001 hv001
rename v002 hv002
rename v003 hvidx
save IRtemp.dta, replace

use MRfile.dta, clear
rename mv* v*
rename v001 hv001
rename v002 hv002
rename v003 hvidx
save IRtemp.dta, replace

use KRfile.dta, clear
rename v001 hv001
rename v002 hv002
rename b16 hvidx
save KRtemp.dta, replace


* append the IR, MR, and KR files
use IRtemp.dta, clear
append using MRtemp.dta
append using KRtemp.dta
sort hv001 hv002 hvidx
save IR_MR_KRtemp.dta, replace


* prepare the PR file and merge with the IR_MR_KR file
use PRfile.dta, clear
sort hv001 hv002 hvidx
save PRtemp.dta, replace
merge hv001 hv002 hvidx using IR_MR_KRtemp.dta


 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Combining KR and PR files
Next Topic: One to one merging
Goto Forum:
  


Current Time: Sun Dec 22 10:40:37 Coordinated Universal Time 2024