Reading a Part of SAS File.: The trailing @ holds a line of data for subsequent INPUT statements,
but releases that line of data when SAS returns to the top of the DATA step to begin building the
next observation.
This tells SAS to hold that
line of raw data. While the trailing @ holds that line, you can test the observation with an IF
statement to see if it’s one you want to keep. If it is, then you can read data for the remaining
variables with a second INPUT statement. Without the trailing @, SAS would automatically start
reading the next line of raw data with each INPUT statement.
Eg:
You want to read part of a raw data file containing local traffic data for freeways and
surface streets. The data include information about the type of street, name of street, the average
number of vehicles per hour traveling that street during the morning, and the average number of
vehicles per hour for the evening. Here are the raw data:
freeway 408 3684 3459
surface Martin Luther King Jr. Blvd. 1590 1234
surface Broadway 1259 1290
surface Rodeo Dr. 1890 2067
freeway 608 4583 3860
freeway 808 2386 2518
surface Lake Shore Dr. 1590 1234
surface Pennsylvania Ave. 1259 1290
Suppose you want to see only the freeway data at this point so you read the raw data file,
Traffic.dat, with this program:
* Use a trailing @, then delete surface streets;
DATA freeways;
INFILE ’c:\MyRawData\Traffic.dat’;
INPUT Type $ @;
IF Type = ’surface’ THEN DELETE;
INPUT Name $ 9-38 AMTraffic PMTraffic;
PROC PRINT DATA = freeways;
TITLE ’Traffic for Freeways’;
RUN;