The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » STATA codes to merge women and household datasets
STATA codes to merge women and household datasets [message #13937] Fri, 26 January 2018 11:53 Go to next message
Mrinal is currently offline  Mrinal
Messages: 12
Registered: January 2018
Location: Bhubaneswar, India
Member
I am working with NFHS datasets and need to merge women and household datasets using STATA, which I hardly use. May I please have the Stata codes to merge aforementioned datasets of all four rounds of NFHS. I will certainly appreciate it.

Thanks and regards,
Mrinal
Re: STATA codes to merge women and household datasets [message #13957 is a reply to message #13937] Mon, 29 January 2018 20:05 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 1504
Registered: February 2013
Senior Member
Following is a response from Senior DHS Stata Specialist, Tom Pullum:

If you want to combine, say, the household (PR) files from the successive surveys, you should use the "append" command. This is distinct from a "merge", in which, say, the KR records and PR records from a single survey could be combined child by child.

Some variables will have different codes and categories in different surveys. For example, v023 may not be defined the same way in every survey. That must be taken into account. When you use the append command, the variable names and labels from the last survey in the append command will over-ride any previous names and labels.

The main reason for appending files is for convenience of file manipulation. In the case of the India surveys, all the files are very large and after appending they will be enormous--and slow to work with. I would recommend trimming the files and just carrying along the variables you need for analysis.

Issues related to appending have been discussed in other forum postings.
Re: STATA codes to merge women and household datasets [message #13961 is a reply to message #13957] Tue, 30 January 2018 03:28 Go to previous messageGo to next message
Mrinal is currently offline  Mrinal
Messages: 12
Registered: January 2018
Location: Bhubaneswar, India
Member
Thank you, Bridgette and Pullum. Actually, I was more interested in merging codes for stata package than appending. However, I managed to construct the merging code for NFHS-2 and is given below.

**Merging household on women dataset**
	**Round 2**
	use "D:\Desktop\dhs\data\nfhs\2\IAHR42FL.DTA", clear
	gen int v001 = hv001
	gen int v002 = hv002
	gen byte v003 = hv003
	sort v001 v002 v003
	save "D:\Dropbox\stata\nfhs\IAHR42FL_sort.DTA", replace
	
	use "D:\Desktop\dhs\data\nfhs\2\IAIR42FL.DTA", clear
	sort v001 v002 v003
	merge v001 v002 v003 using "D:\Dropbox\stata\nfhs\IAHR42FL_sort.DTA"
    
	save "D:\Desktop\dhs\data\nfhs\2\IA_HR_IR_42FL.DTA", replace


Thanks and regards,
Mrinal
Re: STATA codes to merge women and household datasets [message #13996 is a reply to message #13961] Thu, 01 February 2018 11:14 Go to previous messageGo to next message
boyle014 is currently offline  boyle014
Messages: 49
Registered: December 2015
Location: Minneapolis
Member
Mrnal,

You should consider using IPUMS-DHS, which has already harmonized all of the variables across the surveys. You select the samples you want--all of the Indian ones it sounds like--and then the variables you want. You don't have to download separate files and merge or append them. You can download a single file with multiple surveys. The latest Indian sample is being uploaded into the system now. It will be available in March. The other three Indian samples are already there.

Liz Boyle



Professor Elizabeth Boyle
Sociology & Law, University of Minnesota, USA
Principal Investigator, IPUMS-DHS
Re: STATA codes to merge women and household datasets [message #14029 is a reply to message #13996] Mon, 05 February 2018 01:07 Go to previous messageGo to next message
Mrinal is currently offline  Mrinal
Messages: 12
Registered: January 2018
Location: Bhubaneswar, India
Member
Dear Elizabeth,

First of all, I would like to thank and congratulate you and your team for the much needed PUMS-DHS initiative. It is such a relief to have a resource like this when working with huge databases such as NFHS. Interestingly, the first thing I did after getting access to DHS was to browse the IPUMS-DHS project, however, I realized that I should take it as an opportunity to learn a thing or two while preparing the database for analysis. But again I heartily appreciate your contribution in smoothening the path to analyze DHS database.


Mrinal
Re: STATA codes to merge women and household datasets [message #14035 is a reply to message #14029] Mon, 05 February 2018 13:08 Go to previous messageGo to next message
boyle014 is currently offline  boyle014
Messages: 49
Registered: December 2015
Location: Minneapolis
Member
Thanks, Mrinal!

Professor Elizabeth Boyle
Sociology & Law, University of Minnesota, USA
Principal Investigator, IPUMS-DHS
Re: STATA codes to merge women and household datasets [message #14536 is a reply to message #13996] Wed, 18 April 2018 18:52 Go to previous messageGo to next message
Gowokani is currently offline  Gowokani
Messages: 7
Registered: October 2016
Location: Malawi
Member
This IPUMS-DHS , is just unavailable. See the message I am getting (attached)

Gowo

  • Attachment: Capture.PNG
    (Size: 38.31KB, Downloaded 103 times)


Gowokani Chijere Chirwa
Re: STATA codes to merge women and household datasets [message #14542 is a reply to message #14536] Fri, 20 April 2018 14:00 Go to previous messageGo to next message
boyle014 is currently offline  boyle014
Messages: 49
Registered: December 2015
Location: Minneapolis
Member
Dear Gowo,

Sorry to hear that you got a Temporarily Unavailable page. We uploaded lots of new data this week. When we do this, the IT people sometimes have to take the website offline for a minute or two to fix bugs. It's working again now!

Liz Boyle


Professor Elizabeth Boyle
Sociology & Law, University of Minnesota, USA
Principal Investigator, IPUMS-DHS
Re: STATA codes to merge women and household datasets [message #16025 is a reply to message #13996] Tue, 23 October 2018 17:18 Go to previous messageGo to next message
priyoma is currently offline  priyoma
Messages: 7
Registered: January 2017
Member
Hi!

I've a similar question. I wish to merge PR file with IR file for NFHS 2( India). I had a look at IPUMS. It is indeed very helpful. However when I try to select variables from two different types of files (IR and PR), the webpage says my selection (data cart) will not be retained.


Any way around this?

I primarily need all of IR variables and education variables of PR (ie education information of each and every member of the household)

Best,
Priyoma
Re: STATA codes to merge women and household datasets [message #16073 is a reply to message #16025] Thu, 01 November 2018 17:20 Go to previous message
boyle014 is currently offline  boyle014
Messages: 49
Registered: December 2015
Location: Minneapolis
Member
Hi priyoma,

Thanks for the query. You've uncovered a temporary weakness with the system when using household members as the unit of analysis--the Household Number (HHID) variable is not available for selection.

To put all the household members' education on each woman's record in IPUMS DHS, you would first create a woman's data file (extract) with all the other variables you need. Then you would go back into the system, select household members as the unit of analysis and create a second extract with the additional variables. You would then merge the files on the HHID variable.

We are in the process of fixing this now. HHID and a few other technical variables will become available for household members extracts next week. We will be adding them when we release a new set of samples from Afghanistan, Angola, Burundi, Lesotho, Myanmar, Namibia, and Senegal. I will post again when that process is complete.


Professor Elizabeth Boyle
Sociology & Law, University of Minnesota, USA
Principal Investigator, IPUMS-DHS
Previous Topic: Issue merging NFHS 2 women and household dataset
Next Topic: Merging from multiple countries
Goto Forum:
  


Current Time: Tue Dec 11 02:42:12 Eastern Standard Time 2018