The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » Linking parents to children
Re: Linking parents to children [message #12503 is a reply to message #12496] Tue, 30 May 2017 15:19 Go to previous message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3214
Registered: February 2013
Senior Member

Following is a response from Senior DHS Stata Specialist, Tom Pullum:


Here are some lines for doing this merge. I used the Cambodia 2014 data files. You need to change the paths as well as the files. I have added in some variables (child_in_PR_file, etc.) that may help with the interpretation but are not really necessary. Good luck....

set more off
use e:\DHS\DHS_data\IR_files\KHIR72FL.dta, clear
sort v001 v002 v003
gen in_IR_file=1
save e:\DHS\DHS_data\scratch\temp.dta, replace
ta
use e:\DHS\DHS_data\PR_files\KHPR72FL.dta, clear
rename hv001 v001
rename hv002 v002
rename hv112 v003
tab v003,m
drop if v003==.
gen child_in_PR_file=1
gen mother_in_hh=1
replace mother_in_hh=0 if v003==0

sort v001 v002 v003
merge v001 v002 v003 using e:\DHS\DHS_data\scratch\temp.dta

tab1 v003 *_file mother* _merge,m
drop if _merge==2

tab _merge mother_in_hh,m

drop _merge

* This file has one record per child
* hv variables refer to the child, v variables refer to the mother
* If the child's mother is not in the household, then mother_in_hh=0

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to merge DHS databases of different countries
Next Topic: Constructiong child data with parental information and other characteristics
Goto Forum:
  


Current Time: Sun Dec 22 04:19:57 Coordinated Universal Time 2024