The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Countries » Nepal » Merging Household+Female+Male files
Merging Household+Female+Male files [message #3575] Mon, 12 January 2015 23:19 Go to next message
UAB_user is currently offline  UAB_user
Messages: 21
Registered: September 2014
Location: Alabama
Member
Hello,

I am looking at male migration in the 2011 Nepal DHS and I want to merge the female file (IR) with the household file (HR) and then merge this to the male file (MR). I know you have to match the male and female files on V001 + V002 + V003 and then match that new data set to the household file using V001 + V002, like what is recommended on the DHS web page, but I am not sure if I did it right since the final number for each merge do not seem to add up.

The Household file has 10826 observations and the female file has 12674 observations. When I merge them with the following SAS code I get 14588 observations.

data derek.full2011;
merge derek.nphr60fl (in=a) derek.npir60fl (in=b) ; by V001 V002 ; run;

The male file has 4121 observations in it and when I merge it into the file above (14588 obs) using the following SAS code I get 18709 observations, which I think means none of the male file merged into my household + female files

data derek.full2011b;
merge derek.full2011 (in=a) derek.npmr60fla (in=b); by V001 V002 V003;
run;


Thank you for the help
Derek
Re: Merging Household+Female+Male files [message #3834 is a reply to message #3575] Fri, 20 February 2015 20:01 Go to previous message
Liz-DHS
Messages: 1516
Registered: February 2013
Senior Member
Dear User,
Here is a response from one of our experts, Dr. Tom Pullum:
Quote:
I would use the following sequence, in Stata terminology (I do not use SAS). First, in the male file, rename the mv* variables to be v*. Then append one file to the other. This is not a merge, it is an append. Then rename v001 to be hv001, v002 to be hv002, and v003 to be hvidx. Then sort the combined file on hv001, hv002, hvidx. Save with a temporary file name such as "IR_MR_temp.dta". Then open the PR file, NOT the HR file, and sort it by hv001, hv002, hvidx. Then merge with "IR_MR_temp.dta". Then save cases that are in both files. Good luck!

Previous Topic: Migration destination in 2006 DHS
Next Topic: Correct numbers for merging the household and individual files of the 2001 DHS Nepal
Goto Forum:
  


Current Time: Thu Mar 28 14:52:11 Coordinated Universal Time 2024