InterviewSolution
Saved Bookmarks
| 1. |
What do you mean by the "+" operator and sum function? |
|
Answer» In SAS, summation or addition is performed either with the “sum” FUNCTION or by using the “+” operator. Function "Sum" returns the sum of arguments that are present (non-missing arguments), WHEREAS "+" operator returns a missing value if one or more arguments are not present or missing. Example: Consider a data set containing three variables a, b, and c. data variabledata; input a b c; cards; 1 2 3 34 3 4 . 3 2 53 . 3 54 4 . 45 4 2 ; run;There are missing VALUES for all variables and we wish to compute the sum of all variables. data sumofvariables; set variabledata; X=sum(a,b,c); y=a+b+c; run;Output: x y 6 6 41 41 5 . 56 . 58 . 51 51The value of y is missing for the 3rd, 4th, and 5th observations in the output. |
|