Functions and CALL Routines under UNIX |
Category: | Character |
UNIX specifics: | Uses ASCII collating 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 collating sequence.
Details |
The COLLATE function returns a string of ASCII characters. The ASCII collating sequence contains 256 positions, referenced with the numbers 0 through 255. Characters above 127 correspond to characters used in European languages as defined in the ISO 8859 character set.
Unless you assign the return value of the COLLATE function to a variable with a defined length less than 200, the ASCII collating sequence string is padded with spaces to a length of 200. If the ASCII collating sequence is greater than 200 characters, you must specify the length for the return string in a LENGTH statement; otherwise, the returned string will be truncated to a length of 200 characters. For more information, see the following examples.
Examples: How SAS Determines the Length of the Return String |
Because the following code does not include a LENGTH statement, the length attribute for the ADDRESS variable is truncated to 200 characters:
data sales; Address=collate(1,241); run; proc contents; run;
Portion of PROC CONTENTS Output
Alphabetic List of Variables and Attributes # Variable Type Len 1 Address Char 200
Because length of ADDRESS is limited to 200 characters, the returned string from the COLLATE function will be limited to 200 characters.
To specify a length greater than 200 characters for a specific variable, you can use the LENGTH statement. In the following code, the length of ADDRESS is specified as 240 characters:
data sales; length Address $240; Address=collate(1,241); run; proc contents; run;
Portion of PROC CONTENTS Output
Alphabetic List of Variables and Attributes # Variable Type Len 1 Address Char 240
Because the length of ADDRESS is set to 240 characters, the returned string from the COLLATE function will contain 240 characters.
See Also |
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.