COLLATE Function: UNIX

Returns a character string in an ASCII collating sequence.
Category: Character
UNIX specifics: Uses ASCII collating sequence
See: COLLATE Function in SAS Functions and CALL Routines: Reference

Syntax

COLLATE(start-position <,end-position> ) | (start-position<,,length> )

Required Argument

start-position
specifies the numeric position in the collating sequence of the first character to be returned.

Optional Arguments

end-position
specifies the numeric position in the collating sequence of the last character to be returned.
length
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

Example 1: Truncating the Variable Length to 200 Characters

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.

Example 2: Specifying a Length Greater Than 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