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.

Transformation Expressions 47<br />

original string remains intact. For example, SUBSTR(ALPHA6,3,1)=’*’<br />

changes the third character of all values for ALPHA6 to *. If the replacement<br />

string is longer or shorter than the substring, the replacement is<br />

truncated or padded with blanks on the right to an equal length.<br />

UPCASE(arg) Convert lower case to upper case. The argument can be a string<br />

variable or a string. For example, UPCASE(NAME1) returns CHARLES<br />

if the value of NAME1 is Charles.<br />

MBLEN.BYTE(arg,a1) Return the number of bytes in the character at the specified position.<br />

The argument is a string expression and a1 indicates the beginning<br />

byte of the character in the specified string.<br />

Search Functions<br />

• The values returned by INDEX and/or RINDEX can be used as arguments to SUBSTR to pull<br />

out substrings with the same beginning or ending character but with varying position and<br />

length.<br />

INDEX(a1, a2, a3) Return a number that indicates the position of the first occurrence of<br />

a2 in a1. a1 is the string that is searched. a2 is the string variable or<br />

string that is used in the search. If a3 is not specified, all of a2 is used.<br />

For example, INDEX(ALPHA8,’**X*’) returns 2 for a case with the value<br />

X**X**X* for the variable ALPHA8. The optional a3 is the number of<br />

characters used to divide a2 into separate strings. Each substring is<br />

used for searching and the function returns the first occurrence of any<br />

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

INDEX(ALPHA8, ’**X*’, 2) and INDEX(ALPHA8, ’**X*’, 1) return 1. a3 must<br />

be a positive integer and must divide evenly into the length of a2. The<br />

target variable must be numeric. If a2 is not found within a1, the value<br />

0 is returned.<br />

LENGTH(arg) Return the length of the specified string. The argument can be a string<br />

variable or a string. For example, LENGTH(LNAME) always returns 6 if<br />

LNAME has an A6 format. The target variable must be numeric.<br />

MAX(arg list) Return the maximum value across the argument list. For example,<br />

MAX(LNAME,FNAME) selects the name that comes last in the sort order,<br />

the first or the last name. MAX is also available as a numeric function.<br />

MIN(arg list) Return the minimum value across the argument list. For example,<br />

MIN(LNAME,FNAME) selects the name that comes first in the sort order,<br />

the first or the last name. MIN is also available as a numeric function.<br />

RINDEX(a1,a2,a3) Return a number indicating the position of the last occurrence of a2 in<br />

a1. a1 is the string that is searched. a2 is the string variable or string<br />

that is used in the search. If a3 is not specified, all of a2 is used. For<br />

example, RINDEX(ALPHA8,’**X*’) returns 5 for a case with the value<br />

X**X**X* for the variable ALPHA8. The optional a3 is the number of<br />

characters used to divide a2 into separate strings. Each substring is<br />

used for searching, and the function returns the last occurrence of any

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

Saved successfully!

Ooh no, something went wrong!