The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » How to link child health outcome with mothers' characteristics
Re: How to link child health outcome with mothers' characteristics [message #28492 is a reply to message #28453] Thu, 18 January 2024 13:43 Go to previous messageGo to previous message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3189
Registered: February 2013
Senior Member
Following is a response from Senior DHS staff member, Tom Pullum:

The following Stata lines will add the mother's data and the household-level data to the child's record. Let us know if you need something else.

* Merge the KR, IR, and HR files for the Tanzania 2022 survey

* specify workspace
cd e:\DHS\DHS_data\scratch

use "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\TZHR82FL.DTA", clear 

* Just keep household-level variables 
drop *_*

gen cluster=hv001
gen hh=hv002
sort cluster hh
save HRtemp.dta, replace

use "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\TZIR82FL.DTA", clear 
gen cluster=v001
gen hh=v002
gen mo_line=v003
sort cluster hh mo_line
save IRtemp.dta, replace

use "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\TZKR82FL.DTA", clear 
gen cluster=v001
gen hh=v002
gen mo_line=v003

* Merge the child with the mother's data
* The KR file already includes many of the mother's variables; they will be over-written
sort cluster hh mo_line
quietly merge cluster hh mo_line using IRtemp.dta
tab _merge
keep if _merge==3
drop _merge

* Merge the child and mother with the household data
sort cluster hh
quietly merge cluster hh using HRtemp.dta
tab _merge
keep if _merge==3
drop _merge

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Merging and appending data files
Next Topic: Merge BDSQ7RDT and BDVA7RDT with the household data file
Goto Forum:
  


Current Time: Thu Nov 7 21:47:59 Coordinated Universal Time 2024