use KEPR70FL.dta, clear
*** Renaming the unique identifiers****
rename hv001 v001
rename hv002 v002
rename hvidx v003
***sorting the variables*******
sort v001 v002 v003
keep v001 v002 v003 hv027
save temp.dta, replace
use KEIR70FL.dta, clear
sort v001 v002 v003
merge v001 v002 v003 using temp.dta
tab _merge
keep if _merge==3
****selected for men's questionnaire / long questionnaire
keep if hv027 == 1
***************************************
gen wt= v005/1000000
gen sex12m=0
replace sex12m=1 if v527>=100 & v527<=311
label define yesno 0 No 1 Yes
label values sex12m yesno
label var sex12m "sex in the last 12 months"
ta sex12m if v501==0 & v013<3 [iw=wt]
* matches percentage of those who had sex in the last 12 months.
ta sex12m v013 if v501==0 & v013<3 [iw=wt], col
gen conduse=0 if sex12m==1 & v501==0 & v013<3
replace conduse=1 if v761==1 & v501==0 & v013<3
* off by 0.1 % and 2 cases
ta conduse v013 [iw=wt], col
]]>