Question

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.

Was it helpful?

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).

OTHER TIPS

  1. Go to "Transform" - "Recode into different variable".
  2. Choose your variable (where you want to exchange 0 by "Missing")
  3. click "Old and new values"
  4. Write under "Old value" - 0
  5. Choose under "New value" - "System-missing"
  6. Click on "add"
  7. Click on "Continue"
  8. Specify the name (label) for the new variable, e.g. "New_with_missing"
  9. Click "OK"
  10. Voila!

Now the new variable "New_with_missing" is created. It will be similar to the old one, but all 0 will become "missing values".

Best,

Eugene

This is an incredibly old question now, but I found that the other two answers were not fit for purpose for me.

My Syntax solution is as follows:

IF (VAR1=0) new = $SYSMIS.

Equally if VAR1 has not been created with a compute _ =0 like new, then a slight change to Christian's answers would be:

IF (Missing(VAR1)) new = $SYSMIS.

I hope this helps anyone else who comes across this as I did!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top