The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » Merging Child and Household data for a new user of Stata
Re: Merging Child and Household data for a new user of Stata [message #26652 is a reply to message #26647] Thu, 13 April 2023 07:15 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:

I don't know for sure which Colombia survey you are using. I will insert below some Stata lines for this merge using the 2015-16 survey. I construct variables "in_PR" and "in_KR", which I sometimes find helpful for diagnosing problems with a merge. This program seems to work fine. It matches 11,231 children in both the PR and KR files.
*KR PR merge using Colombia 2015-16

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

* prepare PR file
use "...COPR72FL.DTA" , clear
gen cluster=hv001
gen hh=hv002
gen line=hvidx

* This survey does not contain hw1. Reduce to children 0-4 years, plus an extra year
*   for possible age discrepancies
drop if hv105>5
gen in_PR=1
sort cluster hh line
save COPRtemp.dta, replace

* prepare KR file and merge
use "...COKR72FL.DTA" , clear
drop if b16==0 | b16==.
gen cluster=v001
gen hh=v002
gen line=b16
gen in_KR=1
sort cluster hh line
merge cluster hh line using COPRtemp.dta
tab _merge
tab in*,m

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Merging KR to MR OR (KR, IR, MR)
Next Topic: How to merge KR and IR
Goto Forum:
  


Current Time: Thu Nov 7 20:38:03 Coordinated Universal Time 2024