LENGTHM Function


LENGTHM Function

Returns the amount of memory (in bytes) that is allocated for a character string

Category: Character

Syntax

LENGTHM ( string )

Arguments

string

  • specifies a character constant, variable, or expression.

Details

The LENGTHM function returns an integer that represents the amount of memory in bytes that is allocated for string . If string is a numeric variable (either initialized or uninitialized ), LENGTHM 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 LENGTHM function returns the amount of memory in bytes that is allocated for a character string, whereas the LENGTH, LENGTHC, and LENGTHN functions return the length of a character string. LENGTHM always returns a value that is greater than or equal to the values returned by LENGTH, LENGTHC, and LENGTHN.

Examples

Example 1: Determining the Amount of Allocated Memory for a Variable with Trailing Blanks

This example determines the amount of memory (in bytes) that is allocated to a variable with trailing blanks.

 data _null_;     x=lengthm('variable with trailing blanks  ');     put x;  run; 

The following line is written to the SAS log:

 32 

Example 2: Determining the Amount of Allocated Memory for a Variable from an External File

This example determines the amount of memory (in bytes) that is allocated to a variable that is input into a SAS file from an external file.

 data _null_;     file 'test.txt';     put 'trailing blanks ';  run;  data test;     infile 'test.txt';     input;     x=lengthm(_infile_);     put x;  run; 

The following line is written to the SAS log:

 256 

See Also

Functions:

  • 'LENGTH Function' on page 627

  • 'LENGTHC Function' on page 628

  • 'LENGTHN Function' on page 631




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