VLENGTH Function
Returns the compile-time (allocated) size of the
specified variable.
Category: |
Variable Information |
Restriction: |
Use only with the DATA step |
Syntax
Required Argument
var
specifies a variable
that is expressed as a scalar or as an array reference.
Restriction |
You cannot use an expression as an argument. |
Comparisons
-
LENGTH examines the variable at
run-time, trimming trailing blanks to determine the length. VLENGTH
returns a compile-time constant value, which reflects the maximum
length.
-
LENGTHC returns the same value
as VLENGTH, but LENGTHC can be used in any calling environment and
its argument can be any expression.
-
VLENGTH returns the length of the
specified variable. VLENGTHX, however, evaluates the argument to
determine the variable name. The function then returns the compile-time
size that is associated with that variable name.
-
VLENGTH does not accept an expression
as an argument. VLENGTHX accepts expressions, but the value of the
specified expression cannot denote an array reference.
-
Related functions return the value
of other variable attributes, such as the variable name, informat,
and format, among others. For a list, see the Variable Information
functions in
SAS Functions and CALL Routines by Category.
Example
The following SAS statements
produce these results.
|
|
length x $8;
x='abc';
y=vlength(x);
z=length(x);
put y=;
put z=;
|
|