The SQL Procedure |
BTRIM (<<btrim-specification> <'btrim-character' FROM>> sql-expression) |
Arguments |
is one of the following:
removes the blanks or specified characters from the beginning of the character string.
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.
Default: | BOTH |
is a single character that is to be removed from the character string. The default character is a blank.
must resolve to a character string or character variable and is described in sql-expression.
Details |
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
btrim(both 'x' from btrim(z))
The inner BTRIM function removes the trailing blanks before passing the value to the outer BTRIM function.
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.