Functions and CALL Routines |
Returns the length of a character string, including trailing blanks.
-
string
-
specifies a character constant, variable,
or expression.
The LENGTHC function returns the number
of characters, both blanks and non-blanks, in string.
If string is a numeric constant, variable or
expression (either initialized or uninitialized), SAS automatically converts
the numeric value to a right-justified character string by using the BEST12.
format. In this case, LENGTHC returns a value of 12 and writes a note in the
SAS log stating that the numeric values have been converted to character values.
-
The LENGTHC function returns the length of a character
string, including trailing blanks, whereas the LENGTH and LENGTHN functions
return the length of a character string, excluding trailing blanks. LENGTHC
always returns a value that is greater than or equal to the value of LENGTHN.
-
The LENGTHC function returns the length of a character
string, including trailing blanks, whereas the LENGTHM function returns the
amount of memory in bytes that is allocated for a character string. For fixed-length
character strings, LENGTHC and LENGTHM always return the same value. For varying-length
character strings, LENGTHC always returns a value that is less than or equal
to the value returned by LENGTHM.
The following SAS statements produce these
results:
SAS Statements |
Results |
x=lengthc('variable with trailing blanks ');
put x;
|
32
|
length fixed $35;
fixed='variable with trailing blanks ';
x=lengthc(fixed);
put x;
|
35
|
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.