Re: Creating some variables [message #28796 is a reply to message #28721] |
Sat, 09 March 2024 06:38 ![Go to previous message Go to previous message](/theme/default/images/up.png) |
SaraDHS
Messages: 44 Registered: December 2020
|
Member |
|
|
Hello,
You were getting close, but some of the conditional statements were slightly off. I have added the correct code below and commented out your earlier code.
Best,
Sara
*Sterilization equipment
gen ste=0
replace ste=1 if (q201==1 | q201==2) & ((q501a_03==1 & q501b_03==1) | (q501a_01==1 & q501b_01==1) | (q501a_02==1 & q501b_02==1 & q501a_06==1 & q501b_06==1))
tab ste [iw=wt]
/*gen ste=0
replace ste=1 if (q201==1 | q201==2) & ((q501a_04==1 & q501b_04==1) | (q501a_01==1 & q501b_01==1) | (q501a_02==1 & q501b_02==1 & q501a_07==1 & q501b_07==1))
tab ste [iw=wt]
*/
*Equipment for high level disinfection
gen hilvldis=0
replace hilvldis=1 if (q201==1 | q201==2) & ((q501a_04==1 & q501b_04==1) | (q501a_05==1 & q501a_06==1 & q501b_06==1) | (q501a_09==1 & (regexm(q502g_5,"C") | regexm(q502g_5,"D") | regexm(q502g_5,"E") | regexm(q502g_5,"F"))))
tab hilvldis [iw=wt]
/*gen hilvldis=0
replace hilvldis=1 if (q201==1 | q201==2) & ((q501a_4==1 & q501b_4==1) | (q501a_5==1) | (q501a_9==1 & inrange(q502g_5,3,5)))
tab hilvldis [iw=wt]
*/
*Client latrine
gen latrine=0
*replace latrine=1 if (q620==11|q620==12)&(q620==21)|(q620==22|q620==31)
replace latrine=1 if q620==11 | q620==12 | q620==13 | q620==14 | q620==15 | q620==21 | q620==22 | q620==31
label var latrine "client latrine"
tab latrine [iw=wt],m
Sara Riese, PhD
Senior Demographic and Health Researcher, DHS Program
|
|
|