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.
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).
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.
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:
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
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;
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. |