SAS 9.1.3 Language Reference: Concepts, Third Edition, Volumes 1 and 2

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:

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.

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:

Output 6.2: SAS Log Results for a Missing Value

1 data a; 2 x= .d; 3 y=x+1; 4 put y=; 5 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 3:6 NOTE: The data set WORK.A has 1 observations and 2 variables. NOTE: DATA statement used: real time 0.58 seconds cpu time 0.05 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 a list of these functions, see the descriptive statistics category in "Functions and CALL Routines by Category" in the SAS Language Reference: Dictionary . 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;

Output 6.3: SAS Log Results for a Missing Value in a Statistic Function

1 data test; 2 x=.; 3 y=5; 4 a=x+y; 5 b=sum(x,y); 6 c=5; 7 c+x; 8 put a= b= c=; 9 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 4:6 NOTE: The data set WORK.TEST has 1 observations and 5 variables. NOTE: DATA statement used: real time 0.11 seconds cpu time 0.03 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.

Категории