The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » Couples and HIV merge in STATA
Re: Couples and HIV merge in STATA [message #3284 is a reply to message #3271] Mon, 17 November 2014 18:22 Go to previous messageGo to previous message
Trevor-DHS is currently offline  Trevor-DHS
Messages: 805
Registered: January 2013
Senior Member
You have to do this twice. Once for women and then once for men. Here is how to merge the AR file with the CR file for women first:

* Step 1: open AR file
use "xxAR61FL.DTA", clear

* Step 2: rename identifying variables
renvars hivclust hivnumb hivline / v001 v002 v003

* Step 3: sort by identifying variables
sort v001 v002 v003

* Step 4: save results
save "xxAR61FL_mergeprep.DTA", replace

* Step 5: open IR file
use "xxCR61FL.DTA", clear

* Step 6: sort by identifying variables
sort v001 v002 v003

* Step 7: merge!
merge v001 v002 v003 using "xxAR61FL_mergeprep.DTA"

* Step 8: Keep only women
drop if _merge==2

Then rename the added hiv variables to something unique for women, e.g.
rename hiv* w_hiv*

and repeat steps 1-8 above using mv003 instead of v003 throughout to merge the men's hiv test result and then finally rename the hiv variables to be for men, e.g.
rename hiv* m_hiv*
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Mother's and Father's occupation
Next Topic: Merging Birth and Household Recodes
Goto Forum:
  


Current Time: Sun Dec 22 16:40:02 Coordinated Universal Time 2024