@ChuksManuel wrote:
Hello,
It's not giving me any error. It's however not giving me what i want. I want the new variable created "abuse" to have 0,1 and missing. With "abuse" called to missing if an observation has missing in all the 5 composite variables. I will appreciate if you can refer me to materials to help me figure this out. I know i'm just missing a small piece of code.
Sounds like you don't need IF/THEN at all. Just use MAX() function.
abuse = max( of ace_swear ace_hurt ace_touch ace_tthem ace_sex);
Let's test the idea by making some data that covers all possible combinations of two variables with 0,1 or . as possible values.
data test;
do x=.,0,1; do y=.,0,1;
want=max(of x y);
output;
end; end;
run;
Result
Obs x y want
1 . . .
2 . 0 0
3 . 1 1
4 0 . 0
5 0 0 0
6 0 1 1
7 1 . 1
8 1 0 1
9 1 1 1
... View more