Syntax - If, with two actions if condition is met...

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Syntax - If, with two actions if condition is met...

spssx100
Hello

I have syntax that looks like this already set up and working well.

IF (VarX=828) VarY="CAW".
IF (VarX=828) VarZ="HEQ".


Can it be simplified into one line, so something like:

If (VarX=820) VarY="CAW" and VarZ="HEQ".?

That doesn't work, but I can't be too far off?!

To clarify, there is one condition to be met, and if it's met, I want to give a value to each of two other variables.
Reply | Threaded
Open this post in threaded view
|

Re: Syntax - If, with two actions if condition is met...

David Marso
Administrator
In 'normal' -whatever that is- SPSS syntax you can have only a single variable assigned per statement in a COMPUTE or IF.
Perhaps you want DO IF.

DO IF (VarX=828).
+  COMPUTE VarY="CAW".
+  COMPUTE VarZ="HEQ".
END IF.


OTOH: In more exotic features of SPSS you can perform multiple assignments.
MATRIX.
COMPUTE VarX=828.
DO IF VarX=828.
COMPUTE VarYZ={"CAW","HEQ"}.
END IF.
PRINT VarYZ / FORMAT "A3".
END MATRIX.

spssx100 wrote
Hello

I have syntax that looks like this already set up and working well.

IF (VarX=828) VarY="CAW".
IF (VarX=828) VarZ="HEQ".


Can it be simplified into one line, so something like:

If (VarX=820) VarY="CAW" and VarZ="HEQ".?

That doesn't work, but I can't be too far off?!

To clarify, there is one condition to be met, and if it's met, I want to give a value to each of two other variables.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Syntax - If, with two actions if condition is met...

spssx100
Thank you David!