New SAS User

Completely new to SAS or trying something new with SAS? Post here for help getting started.
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

Can anyone please clarify the following for me?  I have two different answers from certification practice exams and I really don't understand.  Example 2 makes sense to me...SUM ignores missing values.  But then there's Example 1 that uses SUM but in that one "missing" makes the total SUM missing.  Any clarification is greatly appreciated - thanks!

Example 1

ACredit = . ;
BCredit = 1;
TotalCredits = sum (ACredit + BCredit) + 2;
    What is the value of TotalCredits?  Answer = Missing numeric value
    Explanation: when the SUM function is called with a single argument, it returns the value of that argument. In this case, it is called    
    with a missing value, so it returns a missing value.


Example 2
ACredit = . ;
BCredit = 1;
TotalCredits = sum (ACredit, BCredit) + 2;
    What is the value of TotalCredits?  Answer = 3
    Explanation: The SUM statement ignores missing values.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
The ACredit+Bcredit is evaluated first inside the brackets and returns a missing value to SUM() which then returns a missing value again.

View solution in original post

2 REPLIES 2
Reeza
Super User
The ACredit+Bcredit is evaluated first inside the brackets and returns a missing value to SUM() which then returns a missing value again.
William_Anthem
Calcite | Level 5

Thank you Reeza, that explains it very well! 

 

I appreciate your help!

 

Bill

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 14209 views
  • 0 likes
  • 2 in conversation