## difference between sum() and +<operator>

Solved
Occasional Contributor
Posts: 19

# difference between sum() and +<operator>

``````data work.passengers;
TransPassengers = 100;
OrigPassengers = .;
Totalusingoperator = OrigPassengers + TransPassengers;
Totalusingfunction = Sum(OrigPassengers,TransPassengers);
put Totalusingoperator;
put Totalusingfunction;
run;``````

Please explain the logic of output why value of Totalusingoperator is . and Totalusingfunction is 100.

Ayushmaan

Accepted Solutions
Solution
‎09-02-2017 11:06 AM
PROC Star
Posts: 1,217

## Re: difference between sum() and +<operator>

[ Edited ]

As you can see in the documentation for the SUM function here,  the SUM function "Returns the sum of the nonmissing arguments.", i.e. the sum function ignores the missing value. On the other hand, when you use a missing value with an arithmetic operator (+, - etc), it returnsa missing value.

All Replies
Solution
‎09-02-2017 11:06 AM
PROC Star
Posts: 1,217

## Re: difference between sum() and +<operator>

[ Edited ]

As you can see in the documentation for the SUM function here,  the SUM function "Returns the sum of the nonmissing arguments.", i.e. the sum function ignores the missing value. On the other hand, when you use a missing value with an arithmetic operator (+, - etc), it returnsa missing value.

☑ This topic is solved.