Search code examples
spss

how to set all 0-Values to missing?


How can i set a missing value? E.g. VAR1 to VAR5 have either a value or are missing.(1 = Hello, else missing). I want to compute a new variable out of these:

Compute new = 0
IF VAR1 = 1 then new = 1
IF VAR2 = 1 then new = 2
IF VAR3 = 1 then new = 3
IF VAR4 = 1 then new = 4
IF VAR5 = 1 then new = 5.

But how can I handle the missings? Since compute needs a "=something" at the beginning all my missings are 0 now. How can I set all 0 values to missing? I tried IF new = 0 then missing. but this is not working.


Solution

  • There is the Missing- function and the missing keyword in SPSS. This works like this:

    IF missing(VAR1) THEN new = $SYSMIS.
    

    Missing is a function and figures out if the value for the case is system-missing (a dot) or a user defined missing value. If yes, the parter after the then is executed. In this case, I told SPSS to assign it a "system missing value", visible as a dot. If you want to use a custom missing value, like "6", you would have to include it in the IF-handling.

    This would look like this:

    MISSING VALUES VAR1 ().
    IF VAR6 = 1 then new = 6.
    
    MISSING VALUES VAR6 new(6).