Hi STATALIST members,
I am trying to label all my (string) variables that are coded as Yes/No with 0=no, 1=yes. I tried to do this with the code mentioned below (in which replace is mentioned as I already defined yesno in one of the many attempts before). After this code I get the following error: factor-variable and time-series operators not allowed
r(101);
label define yesno 0 "no" ///
1 "yes" , replace
foreach v of varlist literacy literacycheck firsthusband bankaccount backaccother childmortality planmorechildren foodsecurity1 foodsecurity2 foodsecurity3 foodsecurity4 foodsecurity5 foodsecurity6 foodsecurity7 foodsecurity8 foodsecurity9 Nutrition_1 Nutrition_2 Nutrition_5 Nutrition_6 Nutrition_7 Nutrition_8 Nutrition_9 Nutrition_10 Toiletshare vegetablegarden assetsmatrix1_1 assetsmatrix1_2 assetsmatrix1_3 assetsmatrix1_4 assetsmatrix1_5 assetsmatrix1_6 assetsmatrix2_10 assetsmatrix2_11 assetsmatrix2_12 assetsmatrix2_13 assetsmatrix2_7 assetsmatrix2_9 assetsmatrix2_8 assetsmatrix3_14 assetsmatrix3_15 assetsmatrix3_16 assetsmatrix3_17 assetsmatrix3_18 assetsmatrix3_19 assetsmatrix3_20 assetsmatrix3_21 mosquitonets socialsupport_1 socialsupport_2 socialsupport_3 socialsupport_4 stereotypes_1 stereotypes_2 stereotypes_3 stereotypes_4 debt {
encode label(yesno) `v', gen(_`v')
order _`v', before(`v')
drop `v'
rename _`v', `v'
}
Would be great if someone would know how to deal with this!
Thank you in advance,
Linda
I am trying to label all my (string) variables that are coded as Yes/No with 0=no, 1=yes. I tried to do this with the code mentioned below (in which replace is mentioned as I already defined yesno in one of the many attempts before). After this code I get the following error: factor-variable and time-series operators not allowed
r(101);
label define yesno 0 "no" ///
1 "yes" , replace
foreach v of varlist literacy literacycheck firsthusband bankaccount backaccother childmortality planmorechildren foodsecurity1 foodsecurity2 foodsecurity3 foodsecurity4 foodsecurity5 foodsecurity6 foodsecurity7 foodsecurity8 foodsecurity9 Nutrition_1 Nutrition_2 Nutrition_5 Nutrition_6 Nutrition_7 Nutrition_8 Nutrition_9 Nutrition_10 Toiletshare vegetablegarden assetsmatrix1_1 assetsmatrix1_2 assetsmatrix1_3 assetsmatrix1_4 assetsmatrix1_5 assetsmatrix1_6 assetsmatrix2_10 assetsmatrix2_11 assetsmatrix2_12 assetsmatrix2_13 assetsmatrix2_7 assetsmatrix2_9 assetsmatrix2_8 assetsmatrix3_14 assetsmatrix3_15 assetsmatrix3_16 assetsmatrix3_17 assetsmatrix3_18 assetsmatrix3_19 assetsmatrix3_20 assetsmatrix3_21 mosquitonets socialsupport_1 socialsupport_2 socialsupport_3 socialsupport_4 stereotypes_1 stereotypes_2 stereotypes_3 stereotypes_4 debt {
encode label(yesno) `v', gen(_`v')
order _`v', before(`v')
drop `v'
rename _`v', `v'
}
Would be great if someone would know how to deal with this!
Thank you in advance,
Linda
Comment