I'm making the switch from 20+ years of SPSS. so bear with me as I learn.
I create a new variable using generate. I want the new variable, teach_any to be populated based on 8 other variables. If ANY of the 8 is the number "1" I want my new variable to be a "1", no matter the values of any of the other variables. If any of the variables is a "2" I want my new variable to be a 2, unless it's already a "1" from the prior step, in which case I don't want it overwritten. Finally, for variables where any of the values is a "3" then I want to write a 3 to my new variable, unless it is already a 1 or 2.
Here's my incorrect approach here:
replace teach_any=1 if class_2==1
replace teach_any=2 if class_2==2
replace teach_any=3 if class_2==3
Step 1 will work, the other two overwrite.
for step 2, I want it to doif there is not a 1 value in the new variable, how would I accomplish this?
I create a new variable using generate. I want the new variable, teach_any to be populated based on 8 other variables. If ANY of the 8 is the number "1" I want my new variable to be a "1", no matter the values of any of the other variables. If any of the variables is a "2" I want my new variable to be a 2, unless it's already a "1" from the prior step, in which case I don't want it overwritten. Finally, for variables where any of the values is a "3" then I want to write a 3 to my new variable, unless it is already a 1 or 2.
Here's my incorrect approach here:
replace teach_any=1 if class_2==1
replace teach_any=2 if class_2==2
replace teach_any=3 if class_2==3
Step 1 will work, the other two overwrite.
for step 2, I want it to doif there is not a 1 value in the new variable, how would I accomplish this?
Comment