Returns the amount of memory (in bytes) that is allocated for a character string
Category: Character
LENGTHM ( string )
string
specifies a character constant, variable, or expression.
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.
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.
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
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
Functions:
'LENGTH Function' on page 627
'LENGTHC Function' on page 628
'LENGTHN Function' on page 631