“sql-expression” on page 351.
is one of the following:
removes the blanks or specified characters from the beginning of the character
removes the blanks or specified characters from the end of the character string.
removes the blanks or specified characters from both the beginning and the end
of the character string.
is a single character that is to be removed from the character string. The default
character is a blank.
The BTRIM function operates on character strings. BTRIM removes one or more
instances of a single character (the value of btrim-character) from the beginning, the end,
or both the beginning and end of a string, depending whether LEADING, TRAILING, or
BOTH is specified. If btrim-specification is not specified, then BOTH is used. If btrim-
character is omitted, then blanks are removed.
Note: SAS adds trailing blanks to character values that are shorter than the length of the
variable. Suppose you have a character variable Z, with length 10, and a value
xxabcxx. SAS stores the value with three blanks after the last x (for a total length of
10). If you attempt to remove all the x characters with
btrim(both 'x' from z)
, then the result is abcxx because PROC SQL sees the trailing characters as blanks,
not the x character. In order to remove all the x characters, use this statement.
btrim(both 'x' from btrim(z))
The inner BTRIM function removes the trailing blanks before passing the value to
the outer BTRIM function.
Refers to columns already calculated in the SELECT clause.