| Functions and CALL Routines | 
Returns a character string in ASCII or EBCDIC collating sequence.
| 
COLLATE (start-position<,end-position>) |
(start-position<,,length>)
 | 
- 
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.  | 
 
In a DATA step,
if the COLLATE function returns a value to a variable that has not previously
been assigned a length, then that variable is given a length of 200 bytes.
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.
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 
 | 
 
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.