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 )
Merging of SA DHS 2016 HIV dataset ZAAR and ZAPR [message #29240] Tue, 14 May 2024 05:24 Go to next message
mnyahuma is currently offline  mnyahuma
Messages: 2
Registered: March 2024
Member
I would like help with the merging of HIV dataset and the ZAPR dataset for SA 2016. I would like to find out if there is an alternative way to combine the HIV data set with ZAPR or combining HIV dataset with both IR and MR so that I can be able to analyses the relationship between HIV and associated risk factors in the survey. I managed to append HIV data with IR and then merged it with MR in order to determine the number of males and females who are positive but I am struggling to combine the datasets in order to determine relationship between HIV and the associated risk factors. Your help is greatly appreciated
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 next message
Janet-DHS is currently offline  Janet-DHS
Messages: 880
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
Re: Merging of SA DHS 2016 HIV dataset ZAAR and ZAPR [message #29273 is a reply to message #29260] Fri, 17 May 2024 09:15 Go to previous message
mnyahuma is currently offline  mnyahuma
Messages: 2
Registered: March 2024
Member
Thank you very much
Previous Topic: Merging 2015 Angola HIV data with standard DHS
Next Topic: Data discrepancy-the Philippines 2022
Goto Forum:
  


Current Time: Wed Nov 13 07:23:17 Coordinated Universal Time 2024