merge child under five with their parents [message #22478] |
Thu, 18 March 2021 08:40 |
Tedy
Messages: 14 Registered: July 2020
|
Member |
|
|
Hello dear dhs database experts. Hello to all forum members. I would like to merge the 2018 Cameroon DHS databases to link children under 5 years old and their parents (father and mother), for a study on parents' employment and children's health measured by weight-for-age, weight-for-height, and height-for-age Z-scores, and also preserve household characteristics. I don't know how to proceed and need your help dear experts. Please I need the detailed process since I don't have a very good knowledge of stata, I am begging you and thanks in advance.
sicerly,
|
|
|
|
|
|
Re: merge child under five with their parents [message #22562 is a reply to message #22560] |
Thu, 01 April 2021 08:54 |
Bridgette-DHS
Messages: 3214 Registered: February 2013
|
Senior Member |
|
|
Following is a response from DHS Research & Data Analysis Director, Tom Pullum:
If there are variables in the IR file that are not in the KR file, you can merge the KR file with the IR file by matching v001 v002 v003 in the KR file with v001 v002 v003 in the IR file and keeping the case if _merge==3. Getting the father's data from the MR file, and merging it onto the KR file, is not easy and it can only be done with a subset of children in the KR file. Both the child and the father have to be alive and in the same household. The following Stata lines will do this merge. There are only 3318 children in the KR file for whom it is possible to attach data from fathers in the MR file. You can attach data from the fathers in the PR file to a slightly larger number of children.
* How to attach hv106 (from the PR file) and mv106 (from the MR file)
* for the father to the record for the child in the KR file
* You will want to save more variables; this is just for illustration
* You need a temporary place to save data files (I use e:\DHS\DHS_data\scratch)
* Prepare the MR file
use "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\CMMR71FL.DTA", clear
keep mv001 mv002 mv003 mv106
gen hv001=mv001
gen hv002=mv002
gen hvidx=mv003
sort hv001 hv002 hvidx
save e:\DHS\DHS_data\scratch\CMtemp.dta, replace
* Prepare the PR file and merge with the MR data
use "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\CMPR71FL.DTA", clear
keep hv001 hv002 hvidx hv106
sort hv001 hv002 hvidx
merge hv001 hv002 hvidx using e:\DHS\DHS_data\scratch\CMtemp.dta
tab _merge
keep if _merge==3
drop _merge
* Prepare file of potential fathers
* hvidx is the father's line
gen fa_line=hvidx
sort hv001 hv002 fa_line
* This is a file of potential fathers with both MR and PR data
save e:\DHS\DHS_data\scratch\CMtemp.dta, replace
* Prepare a file of children in the PR file who are age 0-4 with father in the hh
* We merge children in the PR file with fathers in the PR file
use "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\CMPR71FL.DTA", clear
* hv114 is father's line if in the hh
keep if hc1<. & hv114>0 & hv114<.
keep hv001 hv002 hvidx hv114
* hvidx is the child's line and hv114 is the father's line
* merge on the father's line
rename hv114 fa_line
sort hv001 hv002 fa_line
merge hv001 hv002 fa_line using e:\DHS\DHS_data\scratch\CMtemp.dta
tab _merge
drop _merge
* This is a file of children in the PR file with their father's data attached
* Prepare this file for merge with KR file
gen v001=hv001
gen v002=hv002
gen b16=hvidx
sort v001 v002 b16
save e:\DHS\DHS_data\scratch\CMtemp.dta, replace
* Prepare the KR file
use "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\CMKR71FL.DTA"
* b16 in the KR file is the child's line in the PR file
keep if b16>0 & b16<.
keep v001 v002 b16
sort v001 v002 b16
merge v001 v002 b16 using e:\DHS\DHS_data\scratch\CMtemp.dta
tab _merge
keep if _merge==3
drop _merge
save e:\DHS\DHS_data\scratch\CMtemp.dta, replace
|
|
|
|
Re: merge child under five with their parents [message #22588 is a reply to message #22570] |
Wed, 07 April 2021 14:26 |
Bridgette-DHS
Messages: 3214 Registered: February 2013
|
Senior Member |
|
|
Following is a response from DHS Research & Data Analysis Director, Tom Pullum:
Virtually all of the information about the mother is always attached to the child in the KR file. In that file, the "v" variables refer to the mother. All you need to do is to keep those variables. Then keep the mv variables that are in the MR file. No additional merging, beyond what I already described, is needed. Just retain the v and mv variables and you should be able to do everything you want to do.
|
|
|