Missing values in DO IF/END IF constructs.
```DO IF A=1.
COMPUTE  B=10.
ELSE.
COMPUTE B=20.
END IF.
EXECUTE.
```

In this simple example, variable B will get a value of 10, if A=1, otherwise B is assigned a value of 20, but only for valid values; for user missing or system missing cases, the result will be SYMIS. In SPSS the result of a logical expression is in fact true, false or missing. In the case of a missing value, SPSS skips everything between DO IF / END IF.

9 is declared missing (user missing on variable A)

A B
1 10
1 10
2 20
2 20
..
820
9.

If you wish to treat missing values differently, you must use one of the missing value functions in the logical expression on the DO IF command, i.e. you must first test for missing values, if you wish to apply a special treatment on them, i.e.

```DO IF MISSING(A).
COMPUTE B=-1.
ELSE IF A=1.
COMPUTE  B=10.
ELSE.
COMPUTE B=20.
END IF.
EXECUTE.
```

The test for missing values must be on the DO IF command if you wish to handle the missing values. (the MISSING() function is true if observation has a user or system missing value. You can use the SYSMIS() function to check specifically for system missing values.

9 is declared missing (user missing on variable A)

A B
1 10
1 10
2 20
2 20
.-1
820
9-1
What does not work

As a consequence and If you attempt to specify a condition handling missing values on an ELSE IF it will simply have no effect at all.

```DO IF  A=1.
COMPUTE B=10.
ELSE IF MISSING(A).
COMPUTE  B=-1.
ELSE.
COMPUTE B=20.
END IF.
EXECUTE.

```

For a case with a missing value, the result of the test A=1 on the DO IF command will yield a missing value, i.e. SPSS will skip to END IF (i.e. the ELSE IF condition here will never be true) and do nothing at all with it. If variable B does not exist, its value will be SYSMIS; if B exists, the value for that case will not be changed.

The results will be identical to the very first example where missing values were not checked for at all!