Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- SAS Procedures
- /
- proc freq percent not exactly 100

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 05-25-2017 06:15 PM
(1115 views)

I found an old thread about proc freq cumulative percent not adding up to exactly 100, but this is a little different. I am doing a frequency (proc freq noprint with an output data set) where there is only one value of the 'tables' variable in the data so the percent itself (not just the cumulative percent) is 100. It looks like 100 when we view the output data, and if we print it out with a format, even if the format is for example 32.28, we get 100.0000000000000000000000000000. However in an 'if' expression it does not compare as being equal to 100 unless we round it.

Why would that be? This is only happening in one of three jobs (same code, different input data). We could add a step to round the value of percent before doing the check for 100, but should that really be necessary? How can we tell under what circumstances it should be necessary to round a percent value of 100% ?

thanks!

4 REPLIES 4

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Internal representations of decimals. computer precision. Old news. The cumulative is adding many decimal values and there is internal computer storage issues with cumulative error.

Round a value when you need an equal comparison.

If round(x,1) = 100 or similar.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

If you can reproduce the issue with a small set of values then post the example data.

If you can reproduce but the set of values is large (more than a hundred say) then open a ticket with Tech Support and ask them to explain.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Are you using a WEIGHT variable or a FREQ variable?

Please post the code and sample data.

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

**If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. **

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.