The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » Merge DHS dataset (Merge DHS dataset)
Merge DHS dataset [message #19598] Sat, 18 July 2020 10:08 Go to next message
Tedy is currently offline  Tedy
Messages: 14
Registered: July 2020
Member
Good evening Dear DHS-experts, I would like to merge the DHS databases of Cameroon by linking children 6-18 years old with their parents (father and mother), with children as the unit of analysis and I am asking for your help please.
Yours sincerely,
Re: Merge DHS dataset [message #19649 is a reply to message #19598] Sat, 25 July 2020 12:17 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3039
Registered: February 2013
Senior Member
Following is a response from DHS Research & Data Analysis Director, Tom Pullum:

The following should work. This is an illustration in which the only covariates are hv106 for the child, and v106 for the mother and mv106 for the father (these variables refer to completed level of education). It appears that in this survey only about 1/3 of the men were subsampled for the men's survey.

You mention 6-18 but the age range for the information about survival and coresidence with the mother and father is 0-17. You could reduce the age range of the children using hv105. Let us know if you have problems with this.

* Example of merging child age 0-17 with mother and father in same household.
  
* Only variables kept other than id are hv106 for child, v106 for mother, and mv106 for father

cd e:\DHS\DHS_data\scratch

* Prepare file of potential mothers
use v001 v002 v003 v106 using "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\CMIR71FL.DTA", clear 
* Specify which of the mother's variables to keep.  Illustrative only
*keep v001 v002 v003 v106
rename v001 hv001
rename v002 hv002
rename v003 mo_line
gen mother=1
sort hv001 hv002 mo_line
save mo_temp.dta, replace

* Prepare file of potential fathers
use mv001 mv002 mv003 mv106 using "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\CMMR71FL.DTA", clear
* Specify which of the father's variables to keep.  Illustrative only
*keep mv001 mv002 mv003 mv106
rename mv001 hv001
rename mv002 hv002
rename mv003 fa_line
gen father=1
sort hv001 hv002 fa_line
save fa_temp.dta, replace

* Prepare file of children 
use hv001 hv002 hvidx hv112 hv114 hv105 hv106 using "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\CMPR71FL.DTA", clear
keep if hv105<=17
* Specify which child variables to keep.  Illustrative only.  Must keep hv112 and hv114
*keep hvidx hv112 hv114 hv106
gen mo_line=hv112
gen mother_is_in_hh=0
replace mother_is_in_hh=1 if mo_line>0 & mo_line<. 
gen fa_line=hv114
gen father_is_in_hh=0
replace father_is_in_hh=1 if fa_line>0 & fa_line<. 
gen child=1
tab hv106

* merge with mother
sort hv001 hv002 mo_line
merge hv001 hv002 mo_line using mo_temp.dta
rename _merge mo_merge

* merge with father
sort hv001 hv002 fa_line
merge hv001 hv002 fa_line using fa_temp.dta
rename _merge fa_merge

* Clean up
drop if child=.
tab hv106

tab v106 mv106,m
Re: Merge DHS dataset [message #19652 is a reply to message #19649] Sun, 26 July 2020 13:38 Go to previous message
Tedy is currently offline  Tedy
Messages: 14
Registered: July 2020
Member
I would like to thank all the experts of the DHS Forum for their availability and the promptness with which they responded to my concern.
Previous Topic: STATA code merge IR and MR into HR files
Next Topic: Merging DHS Pakistan 2017-18
Goto Forum:
  


Current Time: Thu Apr 25 03:48:41 Coordinated Universal Time 2024