The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » Nutrition and Anthropometry » merge child under five with their parents (father, mother and child merging)
merge child under five with their parents [message #22478] Thu, 18 March 2021 08:40 Go to next message
Tedy is currently offline  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 #22486 is a reply to message #22478] Fri, 19 March 2021 07:15 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3017
Registered: February 2013
Senior Member

Following is a response from DHS Research & Data Analysis Director, Tom Pullum:

Are you using Stata? That's the main package used by the DHS analysis team. Have you looked at the different data files? The KR file has children under five as cases, and most of the mother's information is included on the child's record. Please look at that file and see if it has the variables you need for the child and the mother. Then look at the MR file and determine which variables from the father you would like to attach to the child. Attaching the father's information is possible for children who have a code other than 0 or NA for hv113 in the household file. Other postings describe that merge but let us know if you have difficulty.

Re: merge child under five with their parents [message #22539 is a reply to message #22486] Mon, 29 March 2021 10:52 Go to previous messageGo to next message
Tedy is currently offline  Tedy
Messages: 14
Registered: July 2020
Member
Good evening dear experts, I thank you for your answer and I come back to you because I am facing huge difficulties. To the question if I use stata, I answer affirmative. To the question whether I have looked at the different data files, I also answer in the affirmative. But unfortunately the KR file does not contain all the variables I need for the mother for my analysis. Also I really don't understand how I can proceed to join the father's information to the children. Therefore, I come very humbly to your expertise to ask you to help me by providing me with concrete syntaxes for the realization of this merge for DHS 2018 of Cameroon.
Thank you for your help.

Re: merge child under five with their parents [message #22560 is a reply to message #22539] Thu, 01 April 2021 06:33 Go to previous messageGo to next message
Tedy is currently offline  Tedy
Messages: 14
Registered: July 2020
Member
Good morning dear experts, I thank you for your answer and I come back to you because I am facing huge difficulties. To the question if I use stata, I answer affirmative. To the question whether I have looked at the different data files, I also answer in the affirmative. But unfortunately the KR file does not contain all the variables I need for the mother for my analysis. Also I really don't understand how I can proceed to join the father's information to the children. Therefore, I come very humbly to your expertise to ask you to help me by providing me with concrete syntaxes for the realization of this merge for DHS 2018 of Cameroon.
Thank you for your help.
Re: merge child under five with their parents [message #22562 is a reply to message #22560] Thu, 01 April 2021 08:54 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3017
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 #22570 is a reply to message #22562] Mon, 05 April 2021 08:48 Go to previous messageGo to next message
Tedy is currently offline  Tedy
Messages: 14
Registered: July 2020
Member
Hi dear experts, I am very grateful for your answer to my preoccupation, I was able to merge the fathers with the children in the same household.But however, another question remains, how to do to also have the mothers and their children in the household, but all in one base so that I can make single parent analysis (mother or father) and two parent (mother and father). the idea being to have in the same base the information of the mother and the father. Thanks in advance.

Re: merge child under five with their parents [message #22588 is a reply to message #22570] Wed, 07 April 2021 14:26 Go to previous message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3017
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.
Previous Topic: Linking children nutritional status with father or couple
Next Topic: PMT INDEX SCORE TO WEALTH INDEX SCORE/WEALTH INDEX
Goto Forum:
  


Current Time: Thu Mar 28 16:44:00 Coordinated Universal Time 2024