SYSMIS, $SYSMIS, and SYSMIS() in SPSS
When using syntax to work with system missing values in SPSS, I've seen SYSMIS, $SYSMIS, and SYSMIS() at various places. How do I use them?
Resolving the problem
You're right that all three are related to system missing values. Each of them should be used in specific context, and any confusion typically causes errors in the output.
1) SYSMIS is an input and output keyword. It is documented in the commands that use this keyword in the Syntax Reference Guide, such as RECODE.
This is what you use when you recode some value(s) into system missing, or to recode system missing value into some other value. For example, the following commands
RECODE v1 (SYSMIS = 99) (10 = SYSMIS).
would recode sysmis missing values to 99, and 10 to system missing.
2) $SYSMIS is a system variable for system missing value. In the Syntax Reference Guide, it is documented in Variables section under Universals section.
It is used when you want to set the values of a numeric variable to system missing. For example, if we have a variable that has three cases,
the following commands
IF (v1 < 2) v1 = $SYSMIS.
would transform the data to:
3) SYSMIS() is a function. It is documented in Transformation Expressions section under Universals section in the Syntax Reference Guide.
This is what is used when you try to specify a condition that a variable has a system missing value. It returns true or 1 if the value is system missing; false or 0 otherwise.
IF SYSMIS(v1) v2 = 1.
What if the condition is if a variable doesn't have system missing values? The syntax is:
IF NOT(SYSMIS(v1)) v2 = 2.