How SAS Handles Invalid Data
An input value is invalid if it has any of the following characteristics:
It requires an informat that is not specified.
It does not conform to the informat specified.
It does not match the input style used. An example is if it is read as standard numeric
data (no dollar sign or informat) but it does not conform to the rules for standard
SAS numbers.
It is out of range (too large or too small).
Operating Environment Information
The range for numeric values is operating environment-specific. See the SAS
documentation for your operating environment for more information.
If SAS reads a data value that is incompatible with the type specified for that variable,
SAS tries to convert the value to the specified type. If conversion is not possible, an
error occurs, and SAS performs the following actions:
sets the value of the variable being read to missing or to the value specified with the
INVALIDDATA= system option.
prints an invalid data note in the SAS log.
sets the automatic variable _ERROR_ to 1 for the current observation.
prints the input line and column number containing the invalid value in the SAS log.
If a line contains unprintable characters, it is printed in hexadecimal form. A scale is
printed above the input line to help determine column numbers.
Reading Missing Values in Raw Data
Representing Missing Values in Input Data
Many collections of data contain some missing values. SAS can recognize these values
as missing when it reads them. You use the following characters to represent missing
values when reading raw data:
numeric missing values
are represented by a single decimal point (.). All input styles except list input also
allow a blank to represent a missing numeric value.
character missing values
are represented by a blank, with one exception: list input requires that you use a
period (.) to represent a missing value.
special numeric missing values
are represented by two characters: a decimal point (.) followed by either a letter or an
underscore (_).
For more information about missing values, see Chapter 5, “Missing Values,” on page
Reading Missing Values in Raw Data 451
Special Missing Values in Numeric Input Data
SAS enables you to differentiate among classes of missing values in numeric data. For
numeric variables, you can designate up to 27 special missing values by using the letters
A through Z, in either upper- or lowercase, and the underscore character (_).
The following example shows how to code missing values by using a MISSING
statement in a DATA step:
data test_results;
missing a b c;
input name $8. Answer1 Answer2 Answer3;
Smith 2 5 9
Jones 4 b 8
Carter a 4 7
Reed 3 5 c
Note that you must use a period when you specify a special missing numeric value in an
expression or assignment statement, as in the following:
However, you do not need to specify each special missing numeric data value with a
period in your input data. For example, the following DATA step, which uses periods in
the input data for special missing values, produces the same result as the input data
without periods:
data test_results;
missing a b c;
input name $8. Answer1 Answer2 Answer3;
Smith 2 5 9
Jones 4 .b 8
Carter .a 4 7
Reed 3 5 .c
proc print;
452 Chapter 21 Reading Raw Data

Get SAS 9.4 Language Reference, 6th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.