The DHS Program User Forum - RDF feed
https://userforum.dhsprogram.com/index.php
merging household and husbands' info to women
https://userforum.dhsprogram.com/index.phpindex.php?t=rview&goto=3976&th=1963#msg_3976
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. ]]>Ogriv2015-03-13T09:58:02-00:00Re: merging household and husbands' info to women
https://userforum.dhsprogram.com/index.phpindex.php?t=rview&goto=4025&th=1963#msg_4025
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.
]]>Bridgette-DHS2015-03-18T16:18:39-00:00Re: merging household and husbands' info to women
https://userforum.dhsprogram.com/index.phpindex.php?t=rview&goto=14781&th=1963#msg_14781
Hassen2018-05-05T11:52:51-00:00