Language Reference

LENGTH Function

LENGTH (matrix) ;

This function is supported by the IML procedure and the iml action.

The LENGTH function takes a character matrix as an argument and produces a numeric matrix as a result. The result matrix has the same dimensions as the argument and contains the lengths of the corresponding string elements in matrix. The length of a string is equal to the position of the rightmost nonblank character in the string. If a string is entirely blank, its length value is set to 1. An example of the LENGTH function follows:

c = {"Hello" "My name is Jenny"};
b = length(c);
print b;

Figure 223: Length of Elements of a Character Matrix

b
516


See also the description of the NLENG function.

Last updated: July 20, 2026