BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ab12nov
Obsidian | Level 7

 

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

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.

View solution in original post

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

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.

pjpnk
Fluorite | Level 6

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?

Pankajwa
T_Hasan
Calcite | Level 5

Thats  of  Accumalting column effect. One need to use RETAIN syntax for retaining the initial  value . Use SUM operator instead

Tarannum

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 15048 views
  • 4 likes
  • 4 in conversation