Previous Page | Next Page

Functions and CALL Routines under OpenVMS

COLLATE Function: OpenVMS



Returns an ASCII collating sequence character string.
Category: Character
OpenVMS specifics: ASCII collating sequence
See: COLLATE Function in SAS Language Reference: Dictionary

Syntax
Details
Examples: How SAS Determines the Length of the Return String
Truncating the Variable Length to 200 Characters
Specifying a Length Greater than 200 Characters
MISSING TOPIC TITLE
See Also

Syntax

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.

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, which can range in value from 0 to 255. Characters 128 to 255 are usually special control characters such as special fonts, but the COLLATE function returns them.

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 blanks 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


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 for 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

Previous Page | Next Page | Top of Page