27.03.2013 Views

SPSS® 12.0 Command Syntax Reference

SPSS® 12.0 Command Syntax Reference

SPSS® 12.0 Command Syntax Reference

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

254 COMPUTE<br />

Operations<br />

• If the target variable already exists, its values are replaced.<br />

• If the target variable does not exist and the assignment expression is numeric, the program<br />

creates a new variable.<br />

• If the target variable does not exist and the assignment expression is a string, the program<br />

displays an error message and does not execute the command.<br />

• COMPUTE is not executed if it contains invalid syntax. New variables are not created and<br />

existing target variables remain unchanged.<br />

Numeric Variables<br />

• New numeric variables created with COMPUTE are assigned a dictionary format of F8.2<br />

and are initialized to the system-missing value for each case (unless the LEAVE command<br />

is used). Existing numeric variables transformed with COMPUTE retain their original<br />

dictionary formats. The format of a numeric variable can be changed with the FORMATS<br />

command.<br />

• All expressions are evaluated in the following order: first functions, then exponentiation,<br />

and then arithmetic operations. The order of operations can be changed with parentheses.<br />

• COMPUTE returns the system-missing value when it doesn’t have enough information to<br />

evaluate a function properly. Arithmetic functions that take only one argument cannot be<br />

evaluated if that argument is missing. The date and time functions cannot be evaluated if<br />

any argument is missing. Statistical functions are evaluated if a sufficient number of<br />

arguments is valid. For example, in the command<br />

COMPUTE FACTOR = SCORE1 + SCORE2 + SCORE3<br />

FACTOR is assigned the system-missing value for a case if any of the three score values<br />

is missing. It is assigned a valid value only when all score values are valid. In the<br />

command<br />

COMPUTE FACTOR = SUM(SCORE1 TO SCORE3).<br />

FACTOR is assigned a valid value if at least one score value is valid. It is system-missing<br />

only when all three score values are missing.<br />

String Variables<br />

• String variables can be modified but not created on COMPUTE. However, a new string<br />

variable can be created and assigned a width with the STRING command and then<br />

assigned new values with COMPUTE.<br />

• Existing string variables transformed with COMPUTE retain their original dictionary<br />

formats. String variables declared on STRING and transformed with COMPUTE retain the<br />

formats assigned to them on STRING.<br />

• The format of string variables cannot be changed with FORMATS. Instead, use STRING to<br />

create a new variable with the desired width and then use COMPUTE to set the values of<br />

the new string equal to the values of the original.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!