The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » HIV » Merging data files (Merging women's files and HIV file)
Re: Merging data files [message #27965 is a reply to message #27957] Thu, 26 October 2023 17:01 Go to previous messageGo to previous message
Janet-DHS is currently offline  Janet-DHS
Messages: 888
Registered: April 2022
Senior Member
Following is a response from DHS staff member, Tom Pullum:

The lines below show how to do this merge in Stata. The DHS analysis team does not use SPSS, but the logic should be similar in SPSS.

* Stata lines to merge the IR and AR files for the Cameroon 2018 DHS survey

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

* Prepare the AR file
use "...CMAR71FL.DTA", clear
gen cluster=hivclust
gen hh=hivnumb
gen line=hivline
sort cluster hh line
save CMARtemp.dta, replace

* Prepare the IR file
use "...CMIR71FL.DTA", clear
gen cluster=v001
gen hh=v002
gen line=v003
sort cluster hh line

* Do the merge
merge 1:1 cluster hh line using CMARtemp.dta

* Cases that are in both files have _merge=3
tab _merge
keep if _merge=3
drop _merge

* Save the merged cases with a new file name
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Measurement of Stigma (Discriminating Attitudes)
Next Topic: South Africa 2016
Goto Forum:
  


Current Time: Mon Nov 25 19:52:56 Coordinated Universal Time 2024