When Missing Values Are Generated by SAS

Propagation of Missing Values in Calculations

SAS assigns missing values to prevent problems from arising. If you use a missing value in an arithmetic calculation, SAS sets the result of that calculation to missing. Then, if you use that result in another calculation, the next result is also missing. This action is called propagation of missing values. SAS prints notes in the log to notify you which arithmetic expressions have missing values and when they were created. However, processing continues.

Illegal Operations

SAS prints a note in the log and assigns a missing value to the result if you try to perform an illegal operation, such as the following:
  • dividing by zero
  • taking the logarithm of zero
  • using an expression to produce a number too large to be represented as a floating-point number (known as overflow)

Illegal Character-to-Numeric Conversions

SAS automatically converts character values to numeric values if a character variable is used in an arithmetic expression. If a character value contains nonnumerical information and SAS tries to convert it to a numeric value, a note is printed in the log, the result of the conversion is set to missing, and the _ERROR_ automatic variable is set to 1.

Creating Special Missing Values

The result of any numeric missing value in a SAS expression is a period. Thus, both special missing values and ordinary numeric missing values propagate as a period.
data a;
      x=.d;
      y=x+1;
      put y=;
   run;
This DATA step results in the following log:
SAS Log Results for a Missing Value
130  data a;
131        x=.d;
132        y=x+1;
133        put y=;
134     run;
y=.
NOTE: Missing values were generated as a result of performing an operation on 
      missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      1 at 132:10   
NOTE: The data set WORK.A has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

Preventing Propagation of Missing Values

If you do not want missing values to propagate in your arithmetic expressions, you can omit missing values from computations by using the sample statistic functions. For example, consider the following DATA step:
data test;
  x=.;
  y=5;
  a=x+y;
  b=sum(x,y);
  c=5;  
  c+x;
  put a= b= c=;
run;
SAS Log Results for a Missing Value in a Statistic Function
143  data test;
144    x=.;
145    y=5;
146    a=x+y;
147    b=sum(x,y);
148    c=5;
149    c+x;
150    put a= b= c=;
151  run;
a=. b=5 c=5
NOTE: Missing values were generated as a result of performing an operation on 
      missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      1 at 146:6   
NOTE: The data set WORK.TEST has 1 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.12 seconds
      cpu time            0.01 seconds
      
Adding X and Y together in an expression produces a missing result because the value of X is missing. The value of A, therefore, is missing. However, since the SUM function ignores missing values, adding X to Y produces the value 5, not a missing value.
Note: The SUM statement also ignores missing values, so the value of C is also 5.