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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

48 Universals<br />

Conversion Functions<br />

of the substrings. With the same value X**X**X* for ALPHA8,<br />

RINDEX (ALPHA8, ’**X*’, 2) returns 7, and RINDEX (ALPHA8, ’**X*’, 1)<br />

returns 8. a3 must be a positive integer and must divide evenly into the<br />

length of a2. The target variable must be numeric. If a2 is not found<br />

within a1, the value 0 is returned.<br />

NUMBER(arg,format) Convert the argument into a number using the specified format. The<br />

argument is string, the format is a numeric format, and the result is<br />

numeric. The string is essentially reread using the format and returned<br />

as a number. For example, NUMBER (XALPHA,F3.1) converts all values<br />

for XALPHA to numbers using the F3.1 format. The function returns the<br />

system-missing value if the conversion is invalid.<br />

STRING(arg,format) Converts the argument into a string using the specified format. The<br />

argument is numeric, the format is a numeric format, and the result is a<br />

string. The number is converted from internal representation according<br />

to the format and then stored as a string. For example, STRING (INCOME,<br />

DOLLAR8) converts the numeric values for INCOME to the dollar format<br />

and returns it as a string value. If the result is shorter than the string<br />

variable that receives the values, it is right-justified. If the result is<br />

longer, it is right-trimmed.<br />

Missing Values in String Expressions<br />

• If the numeric argument (which can be an expression) for functions LPAD and RPAD is<br />

illegal or missing, the result is a null string. If the padding or trimming is the only<br />

operation, the string is then padded to its entire length with blanks. If the operation is<br />

nested, the null string is passed to the next nested level.<br />

• If a numeric argument to SUBSTR is illegal or missing, the result is a null string. If SUBSTR<br />

is the only operation, the string is blank. If the operation is nested, the null string is passed<br />

to the next nested level.<br />

• If a numeric argument to INDEX or RINDEX is illegal or missing, the result is system-missing.<br />

Logical Expressions<br />

Logical expressions can appear on the IF, SELECT IF, DO IF, ELSE IF, LOOP IF, and END<br />

LOOP IF commands. SPSS evaluates a logical expression as true or false, or as missing if<br />

it is indeterminate. A logical expression returns 1 if the expression is true, 0 if it is false,<br />

or system-missing if it is missing. Thus, logical expressions can be any expressions that<br />

yield this three-value logic.<br />

• The simplest logical expression is a logical variable. A logical variable is any numeric<br />

variable that has values 1, 0, or system-missing. Logical variables cannot be strings.

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

Saved successfully!

Ooh no, something went wrong!