Creating some variables [message #28721] |
Thu, 29 February 2024 04:57 |
shakim
Messages: 10 Registered: January 2021
|
Member |
|
|
Dear Sara and SPA experts,
I am working with the 2021/22 Ethiopia SPA survey and looking to create three variable equipment for high level disinfection,sterilization equipment (table 3.5.1) and client latrine (table 3.3) using the footnotes and questionnaire. Unfortunately, I am not getting the % of the final report table.
My STATA code is:
gen wt=facwt/1000000
*Sterilization equipment
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_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)
label var latrine "client latrine"
tab latrine [iw=wt],m
Do I need to consider anything else? Would it be possible to get the codes of these variables? I would greatly appreciate any help with this matter.
Many thanks
|
|
|
Re: Creating some variables [message #28796 is a reply to message #28721] |
Sat, 09 March 2024 06:38 |
SaraDHS
Messages: 46 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
|
|
|