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
- /
- question regarding PROC TABULATE

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

04-11-2012 02:17 PM

Hi All,

I am new to SAS and learning PROC TABULTE.

As per my understanding "**Locomotion ALL" **

should print total value of respective column in the last row.

But it is printing mean instead of addition ( ie $37.09, $61.25, $27.63).

Can any body explain me why ?

DATA boats;

INFILE 'c:\MyRawData\Boats.dat';

INPUT Name $ 1-12 Port $ 14-20 Locomotion $ 22-26 Type $ 28-30

Price 32-36;

RUN;

* PROC TABULATE report with options;

PROC TABULATE DATA = boats FORMAT=DOLLAR9.2;

CLASS Locomotion Type;

VAR Price;

** TABLE Locomotion ALL, MEAN*Price*(Type ALL) <=====================================**

/BOX='Full Day Excursions' MISSTEXT='none';

TITLE;

RUN;

table output:

Input data for above is given below.

Silent Lady Maalea sail sch 75.00

America II Maalea sail yac 32.95

Aloha Anai Lahaina sail cat 62.00

Ocean Spirit Maalea power cat 22.00

Anuenue Maalea sail sch 47.50

Hana Lei Maalea power cat 28.99

Leilani Maalea power yac 19.99

Kalakaua Maalea power cat 29.50

Reef Runner Lahaina power yac 29.95

Blue Dolphin Maalea sail cat 42.95

Thanks....................

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

Posted in reply to temp_sha

04-11-2012 02:28 PM

Try Locomotion*mean ALL*sum, Price*(Type ALL)

PG

PG

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

Posted in reply to PGStats

04-11-2012 02:44 PM

Thanks. But I think you did not get my question.

My doubt is why **TABLE Locomotion ALL** is calculating mean

instead of total.

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

Posted in reply to temp_sha

04-11-2012 02:51 PM

You have my sympathies. "New to SAS" and "learning PROC TABULATE" don't always make a pleasant combination.

Think of each cell in PROC TABULATE as reflecting:

- a subset of the observations, based on CLASS variables

- one analysis variable (from the VAR statement)

- one statistic for that analysis variable

The only statistic you ask for is MEAN. That's why you get the mean.

Good luck.

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

Posted in reply to Astounding

04-11-2012 03:24 PM

Sorry. But still I could not get it.

**TABLE Locomotion ALL , MEAN*Price*(Type ALL)**

there are two dimentions in the table row and column.

hence Locomotion ALL should give addition in the table.

I went thrught the documentation can you please let me know

the difference between the two keywords as well ?

ALL adds a row, column, or page showing the total

SUM the sum

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

Posted in reply to temp_sha

04-11-2012 03:45 PM

ALL - refers to group levels, think what goes in the row/column headers

SUM is the statistic to be calculated, ie what goes in the table values.

So specifying ALL with the mean statistic creates a row/column level with ALL and the value for that column/row will be the statistic requested over ALL of the values.

Hope that helps!

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

Posted in reply to temp_sha

04-11-2012 06:15 PM

ALL adds a category to a CLASS variable, if Locomotion = (power, sail) then

"Locomotion ALL" = (power, sail, power and sail)

Such classes define the rows and columns of your table. To put some content in the table cells, you also need a variable and a statistic. In your case, you want both the Mean and Sum statistics. The Mean for the individual Locomotion categories and the Sum for the ALL category. If you didn't care about Type, this would be expressed as:

"Locomotion*Mean ALL*Sum, Price" = (Mean(Price) for power, Mean(Price) for sail, Sum(Price) for power and sail)

Everybody aggrees proc tabulate is not easy to master, but quite powerful once you get it. Start with something simple that works and play with it.

Good luck

PG

PG