The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » merging male and female hiv data to couples data (DRC)
merging male and female hiv data to couples data (DRC) [message #10290] Wed, 20 July 2016 06:46 Go to previous message
jessi.petz is currently offline  jessi.petz
Messages: 2
Registered: July 2016
Location: London
Member
I've followed previous steps provided on merging HIV data to couples data, and managed to merge the women's data fine. But when I go back to do the steps again to merge the men's data it says ~variable _merge already defined~ and does not merge the data.

These are the steps I was following:

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

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

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

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

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


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

* Step 7: merge!
merge 1:1 v001 v002 v003 using "hiv_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 hiv03 w_hiv03
rename hiv01 w_hiv01
rename hiv02 w_hiv02

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*

Is there a different way to get the male data to merge?

Thanks
 
Read Message
Read Message
Previous Topic: Merging data
Next Topic: Merging datasets of different rounds- longitudinal
Goto Forum:
  


Current Time: Sun Apr 28 17:08:44 Coordinated Universal Time 2024