BookmarkSubscribeRSS Feed
Walternate
Obsidian | Level 7

Hi all,

I am trying to get the sum of a column in a dataset. I tried using both proc means and proc sql, but in both cases, the number of digits in the sum exceeded the length of the variable. I'm not sure how to program a longer length into either of those functions. I tried to do it in proc sql like this:

proc sql;

create table new as

select sum(var) as sum_var length=50 from have;

quit;

The code worked, but ignored my length statement.

Any help is much appreciated.

3 REPLIES 3
haikuobian
Fluorite | Level 6

Not sure I understand your issue, but the length of numeric variable in SAS is 3-8, with 8 as the default. In other words, assign a length greater than 8 will have no effect.

Haikuo

stat_sas
Ammonite | Level 13

Tyr this.

proc sql;

create table new as

select sum(var) as sum_var format=best16. from have;

quit;

jakarman
Barite | Level 11

Check in the documentation the numeric precision chapters.

There are no fixed numbers as all is floating based on internal 8 bytes.

The limit of meaningful digits is about 12

What you are probably looking for is the layout of the result.

That one is the format of the result

---->-- ja karman --<-----

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!

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.

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
  • 1502 views
  • 0 likes
  • 4 in conversation