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?

Michael
  • 133
  • 1
  • 1
  • 4

1 Answers1

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.
Jignesh Sutar
  • 2,909
  • 10
  • 13