The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » HIV » South Africa 2016 (Merging Individual record (women) and HIV dataset - South Africa 2016)
Re: South Africa 2016 [message #28136 is a reply to message #28112] Thu, 16 November 2023 14:39 Go to previous message
Janet-DHS is currently offline  Janet-DHS
Messages: 893
Registered: April 2022
Senior Member
Following is a response from DHS staff member, Tom Pullum:

The Stata lines below show how to merge the AR file with both the women and the men. Of the 4862 cases in the AR file, 2136 are men and 2726 are women. These numbers are fairly close, and the difference is mainly due to higher refusal rates (for HIV testing) for men than for women. The number of cases in the IR file (8514) does not tell you anything about how many men are in the AR file.

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

* Prepare AR file
use "...ZAAR71FL.DTA", clear
gen cluster=hivclust
gen hh=hivnumb
gen line=hivline
gen in_AR=1
sort cluster hh line
save ARtemp.dta, replace


* Prepare IR file
use "...ZAIR71FL.DTA", clear
gen cluster=v001
gen hh=v002
gen line=v003
gen sex=2
keep cluster hh line sex
save IRtemp.dta, replace

* Prepare MR file
use "...ZAMR71FL.DTA", clear
gen cluster=mv001
gen hh=mv002
gen line=mv003
gen sex=1
keep cluster hh line sex
save MRtemp.dta, replace

* Append IR and MR and merge with AR
append using IRtemp.dta
sort cluster hh line
merge cluster hh line using ARtemp.dta

keep if _merge==3
tab sex if in_AR==1
 
Read Message
Read Message
Previous Topic: Merging data files
Next Topic: Merging HIV with Standard DHS datasets
Goto Forum:
  


Current Time: Sat Nov 30 18:41:34 Coordinated Universal Time 2024