Chapter 5
Missing Values
Definition of Missing Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Creating Special Missing Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Order of Missing Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Numeric Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Character Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
When Variable Values Are Automatically Set to Missing by SAS . . . . . . . . . . . . . . 86
When Reading Raw Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
When Reading a SAS Data Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
When Missing Values Are Generated by SAS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Propagation of Missing Values in Calculations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Invalid Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Invalid Character-to-Numeric Conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Creating Special Missing Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Preventing Propagation of Missing Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Working with Missing Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
How to Represent Missing Values in Raw Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
How to Set Variable Values to Missing in a DATA Step . . . . . . . . . . . . . . . . . . . . . 90
How to Check for Missing Values in a DATA Step . . . . . . . . . . . . . . . . . . . . . . . . . 90
Definition of Missing Values
missing value
is a value that indicates that no data value is stored for the variable in the current
observation. There are three types of missing values:
• numeric
• character
• special numeric
By default, SAS prints a missing numeric value as a single period (.) and a missing
character value as a blank space. See “Creating Special Missing Values” on page
84 for more information about special numeric missing values.
83