I am trying to create an "index" variable (*mathematically not an index) that I called 'Res' from the other variables in my data set. Here is the code I am trying to use:
COMPUTE Res = 0.
EXECUTE.
DO IF(Q33 = 6).
COMPUTE RES = Res - 1.
IF(Q34 = 7).
COMPUTE Res = Res - 1.
IF(Q35 = 1 OR Q35 = 2).
COMPUTE Res = Res + 1.
END IF.
EXECUTE.
This is not working though - my variable does not change. Tried with ELSE IF and that does change the variable but of course that only implements one change because of the "else" - only one change gets implemented.
To clarify I am trying to compute a score for Res, so I want the algebraic operations performed step by step. So, for instance, for a respondent who has
Q33 = 6, Q34 = 7 and Q 35 = 2
all 3 if conditions are true so Res should be 0 -1 -1 +1 = -1
For a respondent who has
Q33 = 2, Q34 = 2 and Q 35 = 1
The first two if conditions are false and the last one is true so Res should be 0 + 1 = 1
For a respondent who has
Q33 = 2, Q34 = 2 and Q 35 = 3
All if conditions are false, so Res should be 0.
Thanks.