Writes character data of varying length.
| Valid in: | in DATA step |
| Category: | Character |
| Alignment: | Left |
specifies the maximum width of the output field for any output line or output file record.
| Default | 8 if the length of the variable is undefined. Otherwise, the default is the length of the variable |
| Range | 1–32767 |
specifies a numeric variable that contains the length of the current value of the character variable. SAS obtains the value of the length-variable by reading it directly from a field that is described in an INPUT statement, reading the value of a variable in an existing SAS data set, or calculating its value.
| Restriction | length-variable cannot be an array reference. |
| Requirement | You must specify length-variable immediately after $VARYINGw. in a SAS statement. |
| Tips | If the value of length-variable is 0, negative, or missing, SAS writes nothing to the output field. |
| If the value of length-variable is greater than 0 but less than w, SAS writes the number of characters that are specified by length-variable. | |
| If length-variable is greater than or equal to w, SAS writes w columns. |
put @10 name $varying12. varlen;
|
Value of name 1
|
Result
|
|---|---|
|
|
----+----1----+----2----+ |
New York 8 |
New York |
Toronto 7 |
Toronto |
Buenos Aires 12 |
Buenos Aires |
Tokyo 5 |
Tokyo |
| 1The value of NAME appears before the value of VARLEN. | |
varlen=length(name); put @10 name $varying12. varlen;The assignment statement determines the length of the varying-length variable. The variable VARLEN contains this length and becomes the length-variable argument to the $VARYING12. format.
|
Values 1
|
Result
|
|---|---|
----+----1----+----2----+ |
|
New York |
New York |
Toronto |
Toronto |
Buenos Aires |
Buenos Aires |
Tokyo |
Tokyo |
| 1The value of NAME appears before the value of VARLEN. | |