COMPUTE
COMPUTE creates new numeric variables or modifies the values of existing string or numeric variables.
COMPUTE target variable=expression
This command does not read the active dataset. It is stored, pending execution with the next command that reads the dataset. See the topic Command Order for more information.
Syntax for the COMPUTE command can be generated from the Compute Variable dialog.
Example
COMPUTE newvar1=var1+var2.
COMPUTE newvar2=RND(MEAN(var1 to var4).
COMPUTE logicalVar=(var1>5).
STRING newString (A10).
COMPUTE newString=CONCAT((RTRIM(stringVar1), stringVar2).
Functions and operators available for COMPUTE are described in .
- Arithmetic operations
- Numeric constants
- Numeric functions
- Arithmetic functions
- Statistical functions
- Random variable and distribution functions
- String functions
- String/numeric conversion functions
- Logical functions
- Relational operators
- NOT logical operator
- AND and OR logical operators
- LAG function
- Missing value functions
- Scoring expressions
- Date and time functions