hi there,
i hope that somebody can help me with the following problem:
in a questionnaire we have sets of questions where multiple answers can be chosen. they are coded 0 for "not ticked" and 1 if "ticked"
(in addition, some of them are coded -98 or -97 if answer is not valid/not applicable).
we now want to recode all of the variables in the set of variables with -99 (thats our third value for "missing") if all of them are 0 and/or -98 or -97
i found a solution, but it seems rather complicated:
is there any possibility using
and
?
i have found a few things, but i am not sure how to do it properly.
thanks a lot for your help.
hanne
i hope that somebody can help me with the following problem:
in a questionnaire we have sets of questions where multiple answers can be chosen. they are coded 0 for "not ticked" and 1 if "ticked"
(in addition, some of them are coded -98 or -97 if answer is not valid/not applicable).
we now want to recode all of the variables in the set of variables with -99 (thats our third value for "missing") if all of them are 0 and/or -98 or -97
i found a solution, but it seems rather complicated:
Code:
gen var1=1 if hh1 == 0 & hh2 == 0 & hh3 == 0 & (hh1_num == -97 | hh1_num == -98) & (hh2_num == -97 | hh2_num == -98) & (hh3_num == -97 | hh3_num == -98)
replace hh1 = -99 if var1 == 1
replace hh2 = -99 if var1 == 1
replace hh3 = -99 if var1 == 1
Code:
foreach
Code:
recode
i have found a few things, but i am not sure how to do it properly.
thanks a lot for your help.
hanne
Comment