| SAS Component Language Dictionary |
| Category: | Character |
| Syntax | |
| Details | |
| Examples | |
| Example 1: Using the LENGTH Function | |
| Example 2: Using the LENGTH Function with NOTRIM | |
| See Also | |
Syntax |
| length=LENGTH(cval,<'NOTRIM' >); |
specifies that trailing blanks should be counted as part of the string length.
| Details |
The resulting value is the position of the right-most nonblank character in the specified string cval.
When NOTRIM is specified, LENGTH returns the length of a string, including trailing blanks.
By default, variables automatically remove leading blanks when values are assigned to them. The $CHAR format and informat must be assigned to a variable in order for leading blanks to be considered in determining the length of a variable.
| Examples |
Return the length of the character variable S:
length s $ 5; s='ab '; l=length(s); put 'L='l;
This program produces the following output:
L=2
Return the length of the character variable S, using the NOTRIM option:
s = 'xy '; l = length(s, 'notrim'); put 'L='l;
This program produces the following output:
L=4
| See Also |
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.