Numeric variables (COMPUTE command)

  • New numeric variables created with COMPUTE are assigned a dictionary format of F8.2 and are initialized to the system-missing value for each case (unless the LEAVE command is used). Existing numeric variables transformed with COMPUTE retain their original dictionary formats. The format of a numeric variable can be changed with the FORMATS command.
  • All expressions are evaluated in the following order: first functions, then exponentiation, and then arithmetic operations. The order of operations can be changed with parentheses.
  • COMPUTE returns the system-missing value when it doesn’t have enough information to evaluate a function properly. Arithmetic functions that take only one argument cannot be evaluated if that argument is missing. The date and time functions cannot be evaluated if any argument is missing. Statistical functions are evaluated if a sufficient number of arguments is valid. For example, in the command

    COMPUTE FACTOR = SCORE1 + SCORE2 + SCORE3.

    FACTOR is assigned the system-missing value for a case if any of the three score values is missing. It is assigned a valid value only when all score values are valid. In the command

    COMPUTE FACTOR = SUM(SCORE1 TO SCORE3).

    FACTOR is assigned a valid value if at least one score value is valid. It is system-missing only when all three score values are missing. See Missing values in numeric expressions for information on how to control the minimum number of non-missing arguments required to return a non-missing result.