Reads character data of varying length.
Category: | Character |
specifies the maximum width of a character field for all the records in an input file.
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 width of the character field in the current record. SAS obtains the value of length-variable by reading it directly from a field that is described in an INPUT statement or by calculating its value in the DATA step.
Restriction | Length-variable cannot be an array reference. |
Requirement | You must specify length-variable immediately after $VARYINGw. in an INPUT statement. |
Tips | If the value of length-variable is negative or missing, SAS reads no data from the corresponding record. |
If the value of length-variable is 0, the value of the variable is a blank character. A value of 0 for length-variable enables you to read zero-length records and fields. | |
If a variable has been read using an informat other than the $VARYING. informat, and then the same data is read into the same variable that uses the $VARYING. informat where length-variable is 0, then the previous value is overwritten with a blank value. | |
If length-variable is greater than 0 but less than w, SAS reads the number of columns that are specified by length-variable. Then SAS pads the value with trailing blanks up to the maximum width that is assigned to the variable. | |
If length-variable is greater than or equal to w, SAS reads w columns. |
input fwidth 1. name $varying9. fwidth;
Data Line
|
Result 1
|
---|---|
----+----1 |
|
5shark |
shark |
3sunfish |
sun |
8bluefish |
bluefish |
1Notice the result of reading the second data line. |
data one;
infile file-specification length=reclen;
input @;
fwidth=reclen-9;
input name $ 1-9
@10 class $varying20. fwidth;
run;