- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
Thanks in Advance,
Ayushmaan
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello - for cumulative sum we use (+) plus sum operator instead of sum function but still we get non-missing value, isn't it. can you please explain why? let me know please you don't get my concern?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thats of Accumalting column effect. One need to use RETAIN syntax for retaining the initial value . Use SUM operator instead