STRIP Function


Returns a character string with all leading and trailing blanks removed

Category: Character

Syntax

STRIP ( string )

Arguments

string

  • is a character constant, variable, or expression.

Details

If the STRIP 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.

The STRIP function returns the argument with all leading and trailing blanks removed. If the argument is blank, STRIP returns a string with a length of zero.

Assigning the results of STRIP to a variable does not affect the length of the receiving variable. If the value that is trimmed is shorter than the length of the receiving variable, SAS pads the value with new trailing blanks.

Note: The STRIP function is useful for concatenation because the concatenation operator does not remove trailing blanks.

Comparisons

The following list compares the STRIP function with the TRIM and TRIMN functions:

  • For strings that are blank, the STRIP and TRIMN functions return a string with a length of zero, whereas the TRIM function returns a single blank.

  • For strings that lack leading blanks, the STRIP and TRIMN functions return the same value.

  • For strings that lack leading blanks but have at least one non-blank character, the STRIP and TRIM functions return the same value.

Note: STRIP( string ) returns the same result as TRIMN(LEFT( string )) , but the STRIP function runs faster.

Examples

The following example shows the results of using the STRIP function to delete leading and trailing blanks.

 options pageno=1 nodate ls=80 ps=60;  data lengthn;     input string $char8.;     original = '*'  string  '*';     stripped = '*'  strip(string)  '*';     datalines;  abcd    abcd      abcd  abcdefgh   x y z  ;  proc print data=lengthn;  run; 
Output 4.51: Results from the STRIP Function
start example
 The SAS System                    1  Obs  string     original   stripped   1  abcd       *abcd    *  *abcd*   2    abcd     * abcd   *  *abcd*   3      abcd   *   abcd *  *abcd*   4  abcdefgh   *abcdefgh*  *abcdefgh*   5   xyz       * x y z  *  *xyz* 
end example
 

See Also

Functions:

  • 'CAT Function' on page 411

  • 'CATS Function' on page 412

  • 'CATT Function' on page 414

  • 'CATX Function' on page 416

  • 'LEFT Function' on page 626

  • 'TRIM Function' on page 862

  • 'TRIMN Function' on page 864




SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 704

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net