Search code examples
spss

How to set a variable to SYSMIS in SPSS depending on an IF-Condition


Lets say for example I have a variable in SPSS named var1 containing ones and zeros. And I have another variable var2 which I want to set to sysmis if var1 = 1.

How can I do that in SPSS?

The line

IF (var1=1) var2 = SYSMIS.

produces an error.


Solution

  • The trick here is to use the system variable $SYSMIS.

    IF (var1=1) var2 = $SYSMIS.
    

    $SYSMIS is documented in Variables section under Universals section in the Syntax Reference Guide.