Previous Page | Next Page

Starting with Raw Data: Beyond the Basics

Review of SAS Tools


Column-Pointer Controls

@ n

moves the pointer to the n column in the input buffer.

+n

moves the pointer forward n columns in the input buffer.

/

moves the pointer to the next line in the input buffer.

#n

moves the pointer to the nth line in the input buffer.


Line-Hold Specifiers

@

(trailing @) prevents SAS from automatically reading a new data record into the input buffer when a new INPUT statement is executed within the same iteration of the DATA step. When used, the trailing @ must be the last item in the INPUT statement.

@@

(double trailing @) prevents SAS from automatically reading a new data record into the input buffer when the next INPUT statement is executed, even if the DATA step returns to the top for another iteration. When used, the double trailing @ must be the last item in the INPUT statement.


Statements

DATALINES;

indicates that data lines immediately follow. A semicolon in the line that immediately follows the last data line indicates the end of the data and causes the DATA step to compile and execute.

INFILE fileref< FLOWOVER | STOPOVER | MISSOVER | TRUNCOVER>;
INFILE 'external-file' <FLOWOVER | STOPOVER | MISSOVER | TRUNCOVER>;

identifies an external file to be read by an INPUT statement. Specify a fileref that has been assigned with a FILENAME statement or with an appropriate operating environment command. Or you can specify the actual name of the external file.

These options give you control over how SAS behaves if the end of a data record is encountered before all of the variables are assigned values. You can use these options with list, modified list, formatted, and column input.

FLOWOVER

is the default behavior. It causes the DATA step to look in the next record if the end of the current record is encountered before all of the variables are assigned values

MISSOVER

causes the DATA step to assign missing values to any variables that do not have values when the end of a data record is encountered. The DATA step continues processing.

STOPOVER

causes the DATA step to stop execution immediately and write a note to the SAS log.

TRUNCOVER

causes the DATA step to assign values to variables, even if the values are shorter than expected by the INPUT statement, and to assign missing values to any variables that do not have values when the end of a record is encountered.

INPUT variable <&> <$>;

reads the input data record using list input. The & (ampersand format modifier) allows character values to contain embedded blanks. When you use the ampersand format modifier, two blanks are required to signal the end of a data value. The $ indicates a character variable.

INPUT variable start-column<end-column>;

reads the input data record using column input. You can omit end-column if the data is only 1 byte long. This style of input enables you to skip columns of data that you want to omit.

INPUT variable : informat;
INPUT variable & informat;

reads the input data record using modified list input. The : (colon format modifier) instructs SAS to use the informat that follows to read the data value. The & (ampersand format modifier) instructs SAS to use the informat that follows to read the data value. When you use the ampersand format modifier, two blanks are required to signal the end of a data value.

INPUT <pointer-control> variable informat;

reads raw data using formatted input. The informat supplies special instructions to read the data. You can also use a pointer-control to direct SAS to start reading at a particular column.

The syntax given above for the three styles of input shows only one variable. Subsequent variables in the INPUT statement may or may not be described in the same input style as the first one. You may use any of the three styles of input (list, column, and formatted) in a single INPUT statement.

Previous Page | Next Page | Top of Page