You are on page 1of 1

What SAS statements would you code to read an external raw data file to a DATA step?

We use SAS statements –


FILENAME – to specify the location of the file
INFILE - Identifies an external file to read with an INPUT statement
INPUT – to specify the variables that the data is identified with.
How do you read in the variables that you need?
Using Input statement with column /line pointers, informats and length specifiers.
Are you familiar with special input delimiters? How are they used?
DLM, DSD are the special input delimiters…
DELIMITER=delim iter( s)
specifies an alternate delimiter (other than a blank) to be used for LIST input
D SD (delimiter-sensitive data)
specifies that when data values are enclosed in quotation marks, delimiters within the value be
treated as character data. The DSD option changes how SAS treats delimiters when you use
LIST input and sets the default delimiter to a comma. When you specify DSD, SAS treats two
consecutive delimiters as a missing value and removes quotation marks from character values
http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a000146932.htm#a000177189
If reading a variable length file with fixed input, how would you prevent SAS from reading the next record if the last
variable didn't have a value?
Options MISSOVER and TRUNCOVER options
MISSOVER prevents an INPUT statement from reading a new input data record if it does not find values in
the current input line for all the variables in the statement. When an INPUT statement reaches the end of the current input
data record, variables without any values assigned are set to missing.
TRUNCOVER overrides the default behavior of the INPUT statement when an input data record is shorter than
the INPUT statement expects. By default, the INPUT statement automatically reads the next input data record.
TRUNCOVER enables you to read variable-length records when some records are shorter than the INPUT statement
expects. Variables without any values assigned are set to missing.

You might also like