Chapter Contents |
Previous |
Next |
Propagation of Missing Values in Calculations |
Illegal Operations |
Illegal Character-to-Numeric Conversions |
Special Missing Values |
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
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 "Sample Statistics" column in Categories and Descriptions of Functions. For a complete description and examples, see 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;
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.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.