The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » Merge BDSQ7RDT and BDVA7RDT with the household data file (Merging verbal autopsy file, service availability file with the household file for bangladesh 17-18)
Re: Merge BDSQ7RDT and BDVA7RDT with the household data file [message #28581 is a reply to message #28573] Thu, 01 February 2024 11:04 Go to previous messageGo to previous message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3199
Registered: February 2013
Senior Member
Following is a response from Senior DHS staff member, Tom Pullum:

I recommend that you think of this as merging the SQ and PR data with the VA data. When you use the VA data, your interest is in the children (up to 8) for whom the mother provides information. The lines given below will do the merge, with one record per mother, as in the VA data. Your next step would probably be to reshape this file into a file that has one record per child.

It is not necessary to include "m:1" or 1:m" in the merge command. Let us know if you have questions.

* BD7R: Merge the PR, VA, and SQ files

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

* Prepare SQ file for merge
use "...BDSQ7RFL.DTA", clear 
gen cluster=coclust
sort cluster
save SQtemp.dta, replace

* Prepare PR file for merge
use "...BDPR7RFL.DTA", clear 
gen cluster=hv001
gen hh=hv002
gen line=hvidx
sort cluster hh line
save PRtemp.dta, replace

* Open the VA file and prepare for merge 
* The VA file has up to 8 records per mother, 1 for each reference child,
use "...BDVA7RFL.DTA", clear 
gen cluster=qncluster
gen hh=qnhnumber
gen line=qnmother 
sort cluster hh line
merge cluster hh line using PRtemp.dta

* Reduce to the mothers who are in both the VA and PR file
tab _merge
keep if _merge==3
drop _merge

* Prepare for merge with the SQ file, which has one record per cluster
sort cluster
merge cluster using SQtemp.dta
tab _merge
keep if _merge==3
drop _merge

* Save this file, which has one record per mother, and reshape for one record per child

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to link child health outcome with mothers' characteristics
Next Topic: Merging datasets for different countries on SPSS
Goto Forum:
  


Current Time: Thu Nov 28 21:16:15 Coordinated Universal Time 2024