3

I am trying to recode multiple variables with one IF statement. SPSS however does not like me doing so (I am probably missing something in the syntax, but I do not know what).

Example syntax:

IF (Var1=X) Var2=1 Var3=2 Var4=1.
Execute.

So I want SPSS to change variable 1, 2 and three if Var1=X. If I write the syntax like the example I get the error: The expression ends unexpectedly (at the start of the Var3=2 recode).

So my question is: how should I write the syntax to get SPSS to recode multiple variables with one IF statement?

1 Answer 1

3

Look up DO IF statement and the distinction between that and a IF statement, to better understand how each operates and help aid answer your question.

* Assuming Var1 is a string else just enter a numeric without quotes .
DO IF (Var1="X").
    COMPUTE Var2=1
    COMPUTE Var3=2
    COMPUTE Var4=1.
END IF.
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, that is exactly what I needed!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.