SUM function returns the sum of non-missing arguments whereas “+” operator returns a missing value if any of the arguments are missing.
Suppose we have a data set containing three variables - X, Y and Z. They all have missing values. We wish to compute sum of all the variables.
The data is shown in the image below :

data mydata2;
set mydata;
a=sum(x,y,z);
p=x+y+z;
run;
The output is shown in the image below :
In the output, value of p is missing for 4th, 5th and 6th observations.
No comments:
Post a Comment