The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » merging household and husbands' info to women
merging household and husbands' info to women [message #3976] Fri, 13 March 2015 05:58 Go to next message
Ogriv is currently offline  Ogriv
Messages: 16
Registered: March 2015
Member
Hello there
I am a new DHS user, and am currently working with Kenya 2010.

I would like to primarily use the women's files, but also need further relevant information from both the household file and some elements regarding the socioeconomic status of their husbands if they have one.

I have already done a successful merge between the women's and the household file, so that each woman in the individual recode has household information assigned.

Next I'm trying to attach husbands' information using the couples' file.

In Stata I sorted on strata, cluster, household and line number of husband in my newly merged women's/household file.

v022 v001 v002 v034 to be precise.

I sorted on the same in the couples' file.

Then I tried a one to one merge on the same variables with the couples file as the master file.

I'm getting the error message: "variables v022 v001 v002 v034 do not uniquely identify observations in the master data"

Do I need to add a country-specific identifier (and if so, which?), or is there a more fundamental problem?

Thanks
S.

[Updated on: Fri, 13 March 2015 10:15]

Report message to a moderator

Re: merging household and husbands' info to women [message #4025 is a reply to message #3976] Wed, 18 March 2015 12:18 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3188
Registered: February 2013
Senior Member
Following is a response from Senior DHS Stata specialist, Tom Pullum:

First, you refer to a Kenya 2010 survey. I will assume that you mean the Kenya 2008-09 survey. I can't find a Kenya 2010 DHS.

Second, when you do these merges, you do not need to include v022. That variable is always determined by v001 and it is superfluous to include it.

If you are only interested in women who are in couples, then it would be simpler to merge the PR file and CR file directly, using the woman's id. For example, you could do the following lines:

* These lines will attach the CR variables to the PR file, using
* the id for the woman, not the man

* You must change the paths

use c:\DHS\DHS_data\CR_files\KECR52FL.dta, clear
gen hv001=v001
gen hv002=v002
gen hvidx=v003
sort hv001 hv002 hvidx
save c:\DHS\DHS_data\CR_files\temp.dta, replace

use c:\DHS\DHS_data\PR_files\KEPR52FL.dta, clear
sort hv001 hv002 hvidx
merge hv001 hv002 hvidx using c:\DHS\DHS_data\CR_files\temp.dta
tab _merge
keep if _merge==3
drop _merge

Here is how I would have done your merge of the IR and PR files

* These lines will attach the IR variables to the PR file, using
* the id for the woman, not the man

* You must change the paths

use c:\DHS\DHS_data\IR_files\KEIR52FL.dta, clear
gen hv001=v001
gen hv002=v002
gen hvidx=v003
sort hv001 hv002 hvidx
save c:\DHS\DHS_data\IR_files\temp.dta, replace

use c:\DHS\DHS_data\PR_files\KEPR52FL.dta, clear
sort hv001 hv002 hvidx
merge hv001 hv002 hvidx using c:\DHS\DHS_data\IR_files\temp.dta
tab _merge
keep if _merge==3
drop _merge

* Then can attach the CR variables if you want

Please let me know if I have not correctly understood what you want to do.

Re: merging household and husbands' info to women [message #14781 is a reply to message #4025] Sat, 05 May 2018 07:52 Go to previous message
Hassen
Messages: 121
Registered: April 2018
Location: Ethiopia,Africa
Senior Member
Thank you helpful information!!

Hassen Ali(Chief Public Health Professional Specialist)
Previous Topic: merging IR and HIV
Next Topic: Mergining PR onto a Combined IR, MR Dataset in SPSS
Goto Forum:
  


Current Time: Thu Nov 7 12:15:31 Coordinated Universal Time 2024