Previous Page | Next Page

Working with Character Variables

Review of SAS Tools


Functions

LEFT (source)

left-aligns the source by moving any leading blanks to the end of the value. The source can be any kind of character expression, including a character variable, a character constant enclosed in quotation marks, or another character function. Because any blanks removed from the left are added to the right, the length of the result matches the length of the source.

SCAN (source,n<,list-of-delimiters>)

selects the nth term from the source. The source can be any kind of character expression, including a character variable, a character constant enclosed in quotation marks, or another character function. To choose the character that divides the terms, use a delimiter; if you omit the delimiter, then SAS divides the terms using a default list of delimiters (the blank and some special characters).

TRIM (source)

trims trailing blanks from the source. The source can be any kind of character expression, including a character variable, a character constant enclosed in quotation marks, or another character function. The TRIM function does not affect the way a variable is stored. If you use the TRIM function to remove trailing blanks and assign the trimmed value to a variable that is longer than that value, then SAS pads the value with new trailing blanks to make the value match the length of the new variable.


Statements

LENGTH variable-list $ number-of-bytes;

assigns a length that you specify in number-of-bytes to the character variable or variables in variable-list. You can assign any number of lengths in a single LENGTH statement, and you can assign lengths to both character and numeric variables in the same statement. Place a dollar sign ($) before the length of any character variable.

Previous Page | Next Page | Top of Page