Removes trailing blanks from character expressions and returns a null string (zero blanks) if the expression is missing
Category: Character
TRIMN ( argument )
argument
specifies any SAS character expression.
If the TRIMN function returns a value to a variable that has not yet been assigned a length, by default the variable length is determined by the length of the first argument.
TRIMN copies a character argument, removes all trailing blanks, and returns the trimmed argument as a result. If the argument is blank, TRIMN returns a null string. TRIMN is useful for concatenating because concatenation does not remove trailing blanks.
Assigning the results of TRIMN 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.
The TRIMN and TRIM functions are similar. TRIMN returns a null string (zero blanks) for a blank string. TRIM returns one blank for a blank string.
SAS Statements | Results |
---|---|
x="A"trimn("")"B"; put x; | AB |
x=" "; z=" > "trimn(x)" < "; put z; | > < |
Functions:
'COMPRESS Function' on page 458
'LEFT Function' on page 626
'RIGHT Function' on page 787
'TRIM Function' on page 862