The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » Bangladesh 2011 DHS: Merging "children" and "male" files
Re: Bangladesh 2011 DHS: Merging "children" and "male" files [message #1658 is a reply to message #1657] Mon, 24 March 2014 16:13 Go to previous message
user-rhs is currently offline  user-rhs
Messages: 132
Registered: December 2013
Senior Member
Hi Skatumuluwa,
You mentioned both SPSS and Stata in your post. The instructions provided below works with Stata.

Sort and merge on v001 and v002. For the male dataset, create variables v001 and v002 from mv001 and mv002 so that both datasets now contain the variables v001 and v002. In Stata, you can sort on multiple variables, e.g.
sort v001 v002

Sort both datasets and save. Now you can merge on v001 and v002. Stata will also ask you to specify if it is a one-to-many (1:m), one-to-one (1:1), many-to-one (m:1), or many-to-many (m:m) match, so be sure to do that in your merge command.


If you are using SPSS, are you using SPSS syntax? You may have greater flexibility in sorting etc. if you are syntax instead of point and click.

Finally: re: caseid: they are created from concatenating v001, v002, and v003, but they are "right-justified," meaning that if any of these variables contain fewer than 3 characters, the blank would go to the left of the number where it starts. For example, if mv001 = 543, mv002=24, and mv003=1, the mcaseid is 543.24..1. If mv001=51, mv002=115, and mv003=1, then mcaseid is .51115..1. Where I have used red-colored periods to denote what would be indicated as a blank space (" ") in the dataset.

hth,
RHS
 
Read Message
Read Message
Previous Topic: Merging Women and Household Member Recode files
Next Topic: merging multiple years when adminitrative divisin have changed
Goto Forum:
  


Current Time: Wed Feb 26 01:19:30 Coordinated Universal Time 2025