Hello,
I am dealing with 11 variables that I want to make into dummy variables. Currently, the variables only have a value of 1 if it applies to the respondent, otherwise it is missing. I want to recode the missing values to 0 if that observation has a 1 in any of the other 10 variables (ie not missing). If all variables are missing for that observation, I want to keep it as missing.
The current code I have is below. This works fine, it is just very cumbersome because I have to do this for all of the variables and switch one variable name out each time. Is there a more efficient way to do this?
Thanks in advance!
I am dealing with 11 variables that I want to make into dummy variables. Currently, the variables only have a value of 1 if it applies to the respondent, otherwise it is missing. I want to recode the missing values to 0 if that observation has a 1 in any of the other 10 variables (ie not missing). If all variables are missing for that observation, I want to keep it as missing.
The current code I have is below. This works fine, it is just very cumbersome because I have to do this for all of the variables and switch one variable name out each time. Is there a more efficient way to do this?
Code:
replace AB = 0 if (AE !=. | AF !=. | AG !=. | AH !=. | AI !=. | AJ !=. | AK !=. | AL !=. | AM !=. | AN !=.) & AB ==.
Comment