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.

46 Universals<br />

• When two strings are compared, the case in which they are entered is significant. The<br />

LOWER and UPCASE functions are useful for making comparisons of strings regardless<br />

of case.<br />

• For certain functions (for example, MIN, MAX, ANY, and RANGE), the outcome will be<br />

affected by case and by whether the string includes numbers or special characters. The<br />

character set in use varies by system. With the ASCII character set, lower case follows<br />

upper case in the sort order. Therefore, if NAME1 is in upper case and NAME2 is in lower<br />

case, MIN(NAME1,NAME2) will return NAME1 as the minimum. The reverse is true with<br />

the EBCDIC character set, which sorts lower case before upper case.<br />

CONCAT(arg list) Concatenate the arguments into a string. String variables and strings can<br />

be intermixed as arguments. For example, CONCAT(A,’**’) creates the<br />

string ABCD** for a case with the value ABCD for the string variable A.<br />

LOWER(arg) Convert upper case to lower case. All other characters remain unchanged.<br />

The argument can be a string variable or value. For example,<br />

LOWER(NAME1) returns charles if the value of NAME1 is CHARLES.<br />

LPAD(a1, a2, a3) Left-pad. The variable a1 is left-padded up to the length specified by a2<br />

using the optional single character a3 as the pad character. a2 must be a<br />

positive integer from 1 to 255. The default pad character is a blank. For<br />

example, LPAD(ALPHA1,10) adds four leading blanks to the target<br />

variable if ALPHA1 has an A6 format. a3 can be any character enclosed<br />

in apostrophes or any expression that yields a single character.<br />

LTRIM(a1, a2) Left-trim. The character a2 is trimmed from the beginning of a1. For<br />

example, LTRIM(ALPHA2,’0’) trims leading zeros from the variable<br />

ALPHA2. a2 can be any character enclosed in apostrophes or any<br />

expression that yields a single character. The default for a2 is a blank.<br />

RPAD(a1, a2, a3) Right-pad. The variable a1 is right-padded up to the length of a2 using<br />

the optional single character a3 as the pad character. a2 must be a<br />

positive integer from 1 to 255. The default pad character is a blank. For<br />

example, RPAD(ALPHA3,8,’*’) adds two trailing asterisks to the target<br />

variable if ALPHA3 has an A6 format. a3 can be any character enclosed<br />

in apostrophes or any expression that yields a single character.<br />

RTRIM(a1, a2) Right-trim. The character a2 is trimmed from the end of a1. For example,<br />

RTRIM(ALPHA4,’*’) trims trailing asterisks from variable ALPHA4.<br />

a2 can be any character enclosed in apostrophes or any expression that<br />

yields a single character. The default for a2 is a blank.<br />

SUBSTR(a1, a2, a3) Substring. This function returns the substring within a1 beginning with<br />

the position specified by a2 and optionally for a length of a3. a2 can be<br />

a positive integer from 1 to the length of a1. a3, when added to a2, should<br />

not exceed the length of a1. If a3 is not specified, the substring is returned<br />

up to the end of a1. For example, if the variable ALPHA5 has an<br />

A6 format, SUBSTR(ALPHA5,3) returns the last four characters of<br />

ALPHA5. SUBSTR (ALPHA5,3,1) returns the third character of ALPHA5.<br />

When used on the left side of an equals sign, the substring is replaced by<br />

the string specified on the right side of the equals sign. The rest of the

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

Saved successfully!

Ooh no, something went wrong!