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.

452 DEFINE—!ENDDEFINE<br />

• The arguments to string manipulation functions can be strings, variables, or even other<br />

macros. A macro argument or another function can be used in place of a string.<br />

• The strings within string manipulation functions must be either single tokens, such as<br />

ABC, or delimited by apostrophes or quotation marks, as in ‘A B C’. See Table 1 for a set<br />

of expressions and their results.<br />

Table 1 Expressions and results<br />

Expression Result<br />

!UPCASE(abc) ABC<br />

!UPCASE(‘abc’) ABC<br />

!UPCASE(a b c) error<br />

!UPCASE(‘a b c’) A B C<br />

!UPCASE(a/b/c) error<br />

!UPCASE(‘a/b/c’) A/B/C<br />

!UPCASE(!CONCAT(a,b,c)) ABC<br />

!UPCASE(!CONCAT(‘a’,‘b’,‘c’)) ABC<br />

!UPCASE(!CONCAT(a, b, c)) ABC<br />

!UPCASE(!CONCAT(‘a ’,‘b ’,‘c ’)) A B C<br />

!UPCASE(!CONCAT(‘a,b,c’)) A,B,C<br />

!QUOTE(abc) ‘ABC’<br />

!QUOTE(‘abc’) abc<br />

!QUOTE(‘Bill”s’) ‘Bill”s’<br />

!QUOTE(“Bill’s”) “Bill’s”<br />

!QUOTE(Bill’s) error<br />

!QUOTE(!UNQUOTE(‘Bill”s’)) ‘Bill”s’<br />

!LENGTH (str) Return the length of the specified string. The result is a character<br />

representation of the string length. !LENGTH(abcdef) returns 6.<br />

If the string is specified with apostrophes around it, each apostrophe<br />

adds 1 to the length. !LENGTH (‘abcdef’) returns 8. If an<br />

argument is used in place of a string and it is set to null, this<br />

function will return 0.<br />

!CONCAT(str1,str2 . . .) Return a string that is the concatenation of the strings. For example,<br />

!CONCAT (abc,def) returns abcdef.<br />

!SUBSTR (str,from,[length]) Return a substring of the specified string. The substring starts at<br />

the from position and continues for the specified length. If the<br />

length is not specified, the substring ends at the end of the input<br />

string. For example, !SUBSTR (abcdef, 3, 2) returns cd.<br />

!INDEX (haystack,needle) Return the position of the first occurrence of the needle in the<br />

haystack. If the needle is not found in the haystack, the function<br />

returns 0. !INDEX (abcdef,def) returns 4.

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

Saved successfully!

Ooh no, something went wrong!