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

I am sure I'm missing something simple that I've been told about before, but for the life of me I can't figure out what it is, and the failure of a simple filter is frustrating me.

I am attempting to compare two reported quantities dispensed from different sources, looking for instances where the quantities do not match, but quantity 1 multiplied by a known package size equals quantity 2.  For example, Pharmacy A says they dispensed 3 bottles of a certain drug.  Each bottle contains 100 pills. The suppliers shows that Pharmacy A dispensed 300 of the drug.  Well 3 * 100 = 300, and for my purposes this is good and I can forget about this line item.  This is the basic logic of my query, and it work so long as the quantities reported are whole numbers, but anytime there is a decimal involved, my filter is returning the line item saying the quantities are not equal.  I have output all the variables involved, including calculated values, so I can see what is being compared, and I don't get it.  For some reason 90 = 90, 120 = 120, but 7.2 != 7.2.  I hope somebody has an answer for me because I'm at a loss.

Thanks in advance.

Chris

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

Probably best to use the ROUND function on these values before comparison.  For more about numerical precision, see:

SAS(R) 9.2 Language Reference: Concepts, Second Edition

And for exhaustive detail:

Numerical precision in SAS

Chris

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

View solution in original post

2 REPLIES 2
ChrisHemedinger
Community Manager

Probably best to use the ROUND function on these values before comparison.  For more about numerical precision, see:

SAS(R) 9.2 Language Reference: Concepts, Second Edition

And for exhaustive detail:

Numerical precision in SAS

Chris

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
Chris_Smith
Calcite | Level 5

Thank you very much.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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