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
- /
- SAS Procedures
- /
- Length in proc means

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
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-31-2014 01:47 PM

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.

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

07-31-2014 02:09 PM

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

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

07-31-2014 02:10 PM

Tyr this.

proc sql;

create table new as

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

quit;

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

08-01-2014 02:25 AM

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 --<-----