SAS Functions and CALL Routines under Windows |
Category: | Character |
Windows specifics: | Uses the ASCII code sequence |
See: | COLLATE Function in SAS Language Reference: Dictionary |
Syntax |
COLLATE (start-position<,end-position>)|(start-position<,,length>) |
specifies the numeric position in the collating sequence of the first character to be returned.
specifies the numeric position in the collating sequence of the last character to be returned.
specifies the number of characters in the returned collating sequence.
Details |
The COLLATE function returns a string of ASCII characters that range in value from 0 to 255. The string that is returned by the COLLATE function begins with the ASCII character that is specified by the start-position argument. If the end-position argument is specified, the string returned by the COLLATE function contains all the ASCII characters between the start-position and end-position arguments. If the length argument is specified instead of the end-position argument, then the COLLATE function returns a string that contains a value for length. The returned string ends, or truncates, with the character having the value 255 if you request a string length that contains characters exceeding this value.
The default length of the return string value is 200 characters. To return a length of 201 to 256 ASCII characters, use a format such as $256 for the return string variable or explicitly define the variable's length, such as length y $260 .
Any programs using the COLLATE function with characters above ASCII 127 (the hexadecimal notation is '7F'x ) can return a different value when used on a PC from another country. Characters above ASCII 127 are national characters and they vary from country to country.
Examples |
In this example, the return code variable y uses the default return string length of 200. Therefore, the COLLATE function returns 200 characters of the collating sequence.
data _null_; y = collate(1,256); put y; run;
By formatting the return code variable to a length greater than 256, the COLLATE function returns 256 characters of the collating sequence.
data _null_; format y $260.; y = collate(1,256); put y; run;
In this example, the return code variable y uses a return string length of 56, and the COLLATE function returns the first 56 characters of the collating sequence.
data _null_; y = collate(,,56); put y; run;
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.