SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
COLLATE Function
Returns an ASCII or EBCDIC collating sequence character string
Category: Character
See: COLLATE Function in the documentation for your operating environment.
Syntax
COLLATE ( start-position <, end-position >) ( start-position <,, length >)
Arguments
start-position
-
specifies the numeric position in the collating sequence of the first character to be returned.
-
Interaction: If you specify only start-position , COLLATE returns consecutive characters from that position to the end of the collating sequence or up to 255 characters , whichever comes first.
end-position
-
specifies the numeric position in the collating sequence of the last character to be returned.
-
The maximum end-position for the EBCDIC collating sequence is 255. For ASCII collating sequences, the characters that correspond to end-position values between 0 and 127 represent the standard character set. Other ASCII characters that correspond to end-position values between 128 and 255 are available on certain ASCII operating environments, but the information that those characters represent varies with the operating environment.
-
Tip: end-position must be larger than start-position
-
Tip: If you specify end-position , COLLATE returns all character values in the collating sequence between start-position and end-position, inclusive.
-
Tip: If you omit end-position and use length , mark the end-position place with a comma.
length
-
specifies the number of characters in the collating sequence.
-
Default: 200
-
Tip: If you omit end-position , use length to specify the length of the result explicitly.
Details
If the COLLATE function returns a value to a variable that has not yet been assigned a length, by default the variable is assigned a length of 200.
If you specify both end-position and length , COLLATE ignores length . If you request a string longer than the remainder of the sequence, COLLATE returns a string through the end of the sequence.
Examples
The following SAS statements produce these results.
| SAS Statements | Results |
|---|---|
| ASCII | ----+----1----+-----2-- |
|
x=collate(48,,10); y=collate(48,57); put @1 x @14 y; |
0123456789 0123456789 |
| EBCDIC | |
|
x=collate(240,,10); y=collate(240,249); put @1 x @14 y; |
0123456789 0123456789 |
See Also
Functions:
-
'BYTE Function' on page 334
-
'RANK Function' on page 779