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.
data mydata2;
set mydata;
a=sum(x,y,z);
p=x+y+z;
run;
The output is shown in the image below :
SUM Function vs PLUS Operator
SAS : SUM Function vs Plus Operator
In the output, value of p is missing for 4th, 5th and 6th observations.