Try the following code:
* Step 1: open AR file
use "TZAR4AFL.DTA", clear
* Step 2: rename identifying variables
rename hivclust v001
rename hivnumb v002
rename hivline v003
* Step 3: sort according to ID vars
sort v001 v002 v003
* Step 4: save results
save "TZAR4AFL_mergeprep.DTA", replace
* Step 5: open IR file
use "TZIR4AFL.DTA", clear
* Step 6: sort by identifying variables
sort v001 v002 v003
* Step 7: merge!
merge 1:1 v001 v002 v003 using "TZAR4AFL_mergeprep.DTA"
* Step 8: Complete the merge
drop if _merge!=3
* drop the merge variable
drop _merge
* Step 9: save women and men data with HIV results added
save "TZIR4AFL_merged.DTA", replace
*Step 10: Split the merged dataset into two datasets, one for men and one for women
* first men
use "TZIR4AFL_merged.DTA", clear
keep if aidsex==1
* rename variables to names for men, and drop a few unneccessary ones
rename v* mv*
rename s* sm*
rename h* mh*
drop awfact*
* rename back the ID variables used for matching
rename mv001 v001
rename mv002 v002
* create man's line number var for matching
clonevar v034=mv003
* sort on the ID variables
sort v001 v002 v034
save "TZIR4AFL_merged_men.DTA", replace
* second women
use "TZIR4AFL_merged.DTA", clear
keep if aidsex==2
* create husband's line number var for matching
clonevar v034=v034_1
* drop women who are unmarried or whose partner does not live in the household
drop if v034==. | v034==0
* sort and save
sort v001 v002 v034
save "TZIR4AFL_merged_women.DTA", replace
*Step 11: Merge women and men as couples
merge m:1 v001 v002 v034 using "TZIR4AFL_merged_men.DTA"
* keep only the couples who matched
drop if _merge!=3
save "TZIR4AFL_merged_couples.DTA", replace