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.

String Transformations<br />

COMPUTE 253<br />

String variables can be modified but cannot be created with COMPUTE. However, a new<br />

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

assigned values by COMPUTE. The assignment expression can include string constants,<br />

string variables, and any of the string functions. All other functions are available for numeric<br />

transformations only.<br />

Basic Specification<br />

The basic specification is a target variable, an equals sign (required), and an assignment<br />

expression.<br />

<strong>Syntax</strong> Rules<br />

• The target variable must be named first, and the equals sign is required. Only one target<br />

variable is allowed per COMPUTE command.<br />

• Numeric and string variables cannot be mixed in an expression. In addition, if the target<br />

variable is numeric, the expression must yield a numeric value; if the target variable is a<br />

string, the expression must yield a string value.<br />

• Each function must specify at least one argument enclosed in parentheses. If a function has<br />

two or more arguments, the arguments must be separated by commas. For a complete<br />

discussion of the functions and their arguments, see “Transformation Expressions” on p. 37.<br />

• You can use the TO keyword to refer to a set of variables where the argument is a list of<br />

variables.<br />

Numeric Variables<br />

• Parentheses are used to indicate the order of execution and to set off the arguments to a<br />

function.<br />

• Numeric functions use simple or complex expressions as arguments. Expressions must be<br />

enclosed in parentheses.<br />

String Variables<br />

• String values and constants must be enclosed in apostrophes or quotation marks.<br />

• When strings of different lengths are compared using the ANY or RANGE functions, the<br />

shorter string is right-padded with blanks so that its length equals that of the longer string.

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

Saved successfully!

Ooh no, something went wrong!