## Sum function statement generating exponential values

Regular Contributor
Posts: 160

# Sum function statement generating exponential values

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

 208991 547245 91914.1 -208991 -91914.1 -547245

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;

Super User
Posts: 8,220

## Re: Sum function statement generating exponential values

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

Super User
Posts: 24,026

## Re: Sum function statement generating exponential values

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

Super User
Posts: 13,942

## Re: Sum function statement generating exponential values

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.

Discussion stats
• 3 replies
• 168 views
• 2 likes
• 4 in conversation