BookmarkSubscribeRSS Feed
JasonNC
Quartz | Level 8

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;

3 REPLIES 3
art297
Opal | Level 21

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

Reeza
Super User

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 🙂

ballardw
Super User

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.

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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