Treatment of missing values in arguments

If the logic of an expression is indeterminate because of missing values, the expression returns a missing value and the command is not executed. The following table summarizes how missing values are handled in arguments to various functions.

Table 1. Missing values in arguments
Function Returns system-missing if

MOD (x1,x2)

x1 is missing, or x2 is missing and x1 is not 0.

MAX.n (x1,x2,...xk)

MEAN.n (x1,x2,...xk)

MIN.n (x1,x2,...x1)

SUM.n (x1,x2,...xk)

Fewer than n arguments are valid; the default n is 1.

CFVAR.n (x1,x2,...xk)

SD.n (x1,x2,...xk)

VARIANCE.n (x1,x2,...xk)

Fewer than n arguments are valid; the default n is 2.

LPAD(x1,x2,x3)

LTRIM(x1,x2)

RTRIM(x1,x2)

RPAD(x1,x2,x3)

x1 or x2 is illegal or missing.

SUBSTR(x1,x2,x3)

x2 or x3 is illegal or missing.

NUMBER(x,format)

STRING(x,format)

The conversion is invalid.

INDEX(x1,x2,x3)

RINDEX(x1,x2,x3)

x3 is invalid or missing.

LAG (x,n)

x is missing n cases previously (and always for the first n cases); the default n is 1.

ANY (x,x1,x2,...xk)

For numeric values, if x is missing or all the remaining arguments are missing, the result is system-missing. For string values, user-missing value are treated as valid values, and the result is never missing.

RANGE (x,x1,x2,...xk1,xk2)

For numeric values, the result is system-missing if:

  • x is missing, or
  • all the ranges defined by the remaining arguments are missing, or
  • any range has a starting value that is higher than the ending value.

A numeric range is missing if either of the arguments that define the range is missing. This includes ranges for which one of the arguments is equal to the value of the first argument in the expression. For example: RANGE(x, x1, x2) is missing if any of the arguments is missing, even if x1 or x2 is equal to x.

For string values, user-missing values are treated as valid values, and the result is only missing if any range has a starting value that is higher than the ending value.

VALUE (x)

x is system-missing.

MISSING (x)

NMISS (x1,x2,...xk)

NVALID (x1,x2,...xk)

SYSMIS (x)

Never.

  • Any function that is not listed in this table returns the system-missing value when the argument is missing.
  • The system-missing value is a displayed as a period (.) for numeric variables.
  • String variables do not have system-missing values. An invalid string expression nested within a complex transformation yields a null string, which is passed to the next level of operation and treated as missing. However, an invalid string expression that is not nested is displayed as a blank string and is not treated as missing.