turn on suggestions

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

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- Sum function statement generating exponential valu...

Topic Options

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-16-2017 02:41 PM

Hi,

proc sql;

create table snp as

select sum(Amount) as amt

from tbl

group by prdct

quit;

When i am summing the amount when the sum value is zero it's generating exponential value. what's causing the problem

I have amounts like below

Amount

208990.99 |

547244.6 |

91914.11 |

-208990.99 |

-91914.11 |

-547244.6 |

I used round function to overcome the problem but curious what caused the problem and using the round function appropriate solution?

This is what i used

proc sql;

create table snp as

select round(sum(Amount),0.01) as amt

from tbl

group by prdct

quit;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to JasonNC

06-16-2017 02:52 PM

My guess is that you're not getting Exponential values but, rather, large numbers being shown using scientific notation.

If so, rather than outputing the sums, output sum(amount)/1000000 and that way you wil get the sum of number of millions.

Art, CEO, AnalystFinder.com

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to art297

06-16-2017 03:00 PM

What @art297 said, but you're getting really small numbers - ie 2.4X10^-13 or something like that? This has to do with numerical precision and how SAS can store numbers. It's a common issue in programming across all languages and more of a binary computer issue. Until we get quantam

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to JasonNC

06-16-2017 03:43 PM

And it may just be that the format is too small to display well.

data _null_; x=12345678; put x= best4.; run;

Displays x as 12E6 because I told it display with only 4 columns. So the closest value SAS can display with 4 columns is the exponential.