LIST Statement

Writes to the SAS log the input data record for the observation that is being processed.
Valid in: DATA step
Category: Action
Type: Executable

Syntax

LIST;

Without Arguments

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

Action
LIST Statement
PUT Statement
Writes when
at the end of each iteration of the DATA step
immediately
Writes what
the input data records exactly as they appear
the variables or literals specified
Writes where
only to the SAS log
to the SAS log, the SAS output destination, or to any external file
Works with
INPUT statement only
any data-reading statement
Handles hexadecimal values
automatically prints a hexadecimal value if it encounters an unprintable character
represents characters in hexadecimal only when a hexadecimal format is given

Examples

Example 1: Listing Records That Contain Missing Data

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
.
;
Log Listing of Missing Data
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.

Example 2: Listing the Record Length of Variable-Length Records

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

Statements: