Numeric variables (COMPUTE command)
- New numeric variables created with
COMPUTE
are assigned a dictionary format ofF8.2
and are initialized to the system-missing value for each case (unless theLEAVE
command is used). Existing numeric variables transformed withCOMPUTE
retain their original dictionary formats. The format of a numeric variable can be changed with theFORMATS
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 commandCOMPUTE 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.