Missing values in string expressions

  • If the numeric argument (which can be an expression) for the functions LPAD and RPAD is illegal or missing, the result is a null string. If the padding or trimming is the only operation, the string is then padded to its entire length with blanks. If the operation is nested, the null string is passed to the next nested level.
  • If a numeric argument to SUBSTR is illegal or missing, the result is a null string. If SUBSTR is the only operation, the string is blank. If the operation is nested, the null string is passed to the next nested level.
  • If a numeric argument to INDEX or RINDEX is illegal or missing, the result is system-missing.

String user-missing values are treated as missing by statistical and charting procedures and missing values functions. They are treated as valid in other transformation expressions.

DATA LIST LIST /stringvar (a1) numvar(f5.2).
BEGIN DATA
"a" 1
"b" 2
"c" 99
END DATA.
MISSING VALUES stringvar ('c') numvar (99).
COMPUTE newnum1=numvar.
STRING newstring (a1).
COMPUTE newstring=stringvar.
DO IF numvar <> 1.
  COMPUTE num_eval=1.
END IF.
DO IF stringvar <> "a".
  COMPUTE string_eval=1.
END IF.
COMPUTE num_missing=missing(numvar).
COMPUTE string_missing=missing(stringvar).
LIST.

stringvar numvar  newnum1 newstring num_eval string_eval num_missing string_missing 
 
a           1.00     1.00 a              .          .           .00          .00 
b           2.00     2.00 b             1.00       1.00         .00          .00 
c          99.00      .   c              .         1.00        1.00         1.00
  • The value of "c" is declared user-missing for stringvar.
  • All three values of stringvar are treated as valid in COMPUTE newstring=stringvar.
  • DO IF stringvar <> "a" is evaluated as true for the value of "c" rather than missing. This returns a value of 1 for the variable string_eval rather than system-missing.
  • The MISSING function recognizes "c" as missing. This returns a value of 1 for the variable string_missing.