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.