LENGTHN Function


LENGTHN Function

Returns the length of a non-blank character string, excluding trailing blanks, and returns 0 for a blank character string

Category: Character

Syntax

LENGTHN ( string )

Arguments

string

  • specifies a character constant, variable, or expression.

Details

The LENGTHN function returns an integer that represents the position of the rightmost non-blank character in string . If the value of string is blank or missing, LENGTHN returns a value of 0. If string is a numeric variable (either initialized or uninitialized ), LENGTHN returns a value of 12 and prints a note in the SAS log that the numeric values have been converted to character values.

Comparisons

  • The LENGTHN and LENGTH functions return the same value for non-blank character strings. LENGTHN returns a value of 0 for blank character strings, whereas LENGTH returns a value of 1.

  • The LENGTHN function returns the length of a character string, excluding trailing blanks, whereas the LENGTHC function returns the length of a character string, including trailing blanks. LENGTHN always returns a value that is less than or equal to the value returned by LENGTHC.

  • The LENGTHN function returns the length of a character string, excluding trailing blanks, whereas the LENGTHM function returns the amount of memory in bytes that is allocated for a character string. LENGTHN always returns a value that is less than or equal to the value returned by LENGTHM.

Examples

SAS Statements

Results

  len=lengthn('ABCDEF');   put len;  
  6  
  len2=lengthn(' ');   put len2;  
   

See Also

Functions:

  • 'LENGTH Function' on page 627

  • 'LENGTHC Function' on page 628

  • 'LENGTHM Function' on page 629




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