Chapter Contents |
Previous |
Next |
TRIM |
Category: | Character |
Syntax | |
Arguments | |
Details | |
Comparisons | |
Examples | |
Example 1: Removing Trailing Blanks | |
Example 2: Concatenating a Blank Character Expression | |
See Also |
Syntax |
TRIM(argument) |
Details |
TRIM copies a character argument, removes all trailing blanks, and returns the trimmed argument as a result. If the argument is blank, TRIM returns one blank. TRIM is useful for concatenating because concatenation does not remove trailing blanks.
Assigning the results of TRIM to a variable does not affect the length of the receiving variable. If the trimmed value is shorter than the length of the receiving variable, SAS pads the value with new blanks as it assigns it to the variable.
Comparisons |
Examples |
These statements and this data line produce these results:
data test; input part1 $ 1-10 part2 $ 11-20; hasblank=part1||part2; noblank=trim(part1)||part2; put hasblank; put noblank; datalines;
Data Line | Results |
---|---|
apple sauce |
----+----1----+----2 |
apple sauce |
|
applesauce |
SAS Statements | Results |
---|---|
x="A"||trim(" ")||"B"; put x; |
A B |
x=" "; y=">"||trim(x)||"<"; put y; |
> < |
See Also |
Functions:
|
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.