Thank you. It worked but I had to change the last keep line from keep if _merge==5 & hml32<. to keep if hw1<.. I do not understand why the former drops all observations of hml32. Thanks.
Afterthought: I observed that it also keeps the hml32 observations if I use keep if hml32<. instead of keep if _merge==5 & hml32<.
It will be interesting to know what the condition _merge==5 does. Thanks a million.
* Specify workspace
cd e:\DHS\DHS_data\scratch
* Nigeria 2018
* Combine hml variables in the PR file with the ml variables in the KR file
use "NGPR7BFL.DTA", clear
keep if hc1<.
rename hv001 cluster
rename hv002 hh
rename hvidx line
keep cluster hh line hml32
sort cluster hh line
save NGPRtemp.dta, replace
use "NGKR7BFL.DTA", clear
keep if b16>0 & b16<.
rename v001 cluster
rename v002 hh
rename b16 line
keep cluster hh line v0* ml* hw*
sort cluster hh line
merge cluster hh line using NGPRtemp.dta
tab hml32 _merge,m
// keep if _merge==3 & hml32<.
keep if hw1<.
drop _merge
tab hml32
tab hw1 hml32
[Updated on: Mon, 24 October 2022 07:52] by Moderator
Report message to a moderator