The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » HIV » Merging of SA DHS 2016 HIV dataset ZAAR and ZAPR (How to merge hiv data set and ZAPR dataset )
Re: Merging of SA DHS 2016 HIV dataset ZAAR and ZAPR [message #29260 is a reply to message #29240] Thu, 16 May 2024 09:42 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:

There are various ways to do this merge. The following lines will work. You need to specify a workspace and your path to the data.
* merge_AR_IR_MR_PR_do_15May2024

* South Africa 2016 DHS, ZA71

 

* specify workspace

cd e:\DHS\DHS_data\scratch

 

* specify path to the data with a scalar

scalar spath="C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata"

local lpath=spath

 

* Prepare the four data files

use "`lpath'\ZAAR71FL.DTA", clear

gen cluster=hivclust

gen hh=hivnumb

gen line=hivline

gen wt=hiv05/1000000

gen in_AR=1

tab in_AR

save ARtemp.dta, replace

 

use "`lpath'\ZAPR71FL.DTA", clear

gen cluster=hv001

gen hh=hv002

gen line=hvidx

keep if hv117==1 | hv118==1

save PRtemp.dta, replace

 

use "`lpath'\ZAIR71FL.DTA", clear

gen cluster=v001

gen hh=v002

gen line=v003

save IRtemp.dta, replace

 

use "`lpath'\ZAMR71FL.DTA", clear

rename mv* v*

gen cluster=v001                    

gen hh=v002

gen line=v003

save MRtemp.dta, replace

 

* Append IR and MR

use IRtemp.dta, clear

append using MRtemp.dta

save IRMRtemp.dta, replace

 

* Merge AR with PR

use ARtemp.dta, clear

merge 1:1 cluster hh line using PRtemp.dta

keep if in_AR==1

drop _merge

 

* Merge with IR+MR

merge 1:1 cluster hh line using IRMRtemp.dta

keep if in_AR==1

drop _merge

 

* Confirm that we have all the cases in the AR file

tab in_AR,m
 
Read Message
Read Message
Read Message
Previous Topic: Merging 2015 Angola HIV data with standard DHS
Next Topic: Data discrepancy-the Philippines 2022
Goto Forum:
  


Current Time: Sun Nov 24 11:31:03 Coordinated Universal Time 2024