Statements |
Valid: | in a DATA step |
Category: | Action |
Type: | Executable |
Syntax | |
Without Arguments | |
Details | |
Comparisons | |
Examples | |
Example 1: Listing Records That Contain Missing Data | |
Example 2: Listing the Record Length of Variable-Length Records | |
See Also |
Syntax |
LIST; |
The LIST statement causes the input data record for the observation being processed to be written to the SAS log.
Details |
The LIST statement operates only on data that is read with an INPUT statement; it has no effect on data that is read with a SET, MERGE, MODIFY, or UPDATE statement.
In the SAS log, a ruler that indicates column positions appears before the first record listed.
For variable-length records (RECFM=V), SAS writes the record length at the end of the input line. SAS does not write the length for fixed-length records (RECFM=F), unless the amount of data read does not equal the record length (LRECL).
Comparisons |
Examples |
This example uses the LIST statement to write to the SAS log any input records that contain missing data. Because of the #3 line pointer control in the INPUT statement, SAS reads three input records to create a single observation. Therefore, the LIST statement writes the three current input records to the SAS log each time a value for W2AMT is missing.
data employee; input ssn 1-9 #3 w2amt 1-6; if w2amt=. then list; datalines; 23456789 JAMES SMITH 356.79 345671234 Jeffrey Thomas . ;
RULE:----+----1----+----2----+----3----+----4----+----5----+---- 9 345671234 10 Jeffrey Thomas 11 .
The numbers 9, 10, and 11 are line numbers in the SAS log.
This example uses as input an external file that contains variable-length ID numbers. The RECFM=V option is specified in the INFILE statement, and the LIST statement writes the records to the SAS log. When the file has variable-length records, as indicated by the RECFM=V option in this example, SAS writes the record length at the end of each record that is listed in the SAS log.
data employee; infile 'your-external-file' recfm=v; input id $; list; run;
Log Listing of Variable-Length Records and Record Lengths
RULE: ----+----1----+----2----+----3----+----4----+----5--- 1 23456789 8 2 123456789 9 3 5555555555 10 4 345671234 9 5 2345678910 10 6 2345678 7
See Also |
|
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.