question regarding PROC TABULATE

Reply
Occasional Contributor
Posts: 8

question regarding PROC TABULATE

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:

Inline image 1 

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

Respected Advisor
Posts: 4,646

Re: question regarding PROC TABULATE

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


PG

PG
Occasional Contributor
Posts: 8

Re: question regarding PROC TABULATE

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

My doubt is why TABLE Locomotion ALL  is calculating mean

instead of total.

Super User
Posts: 5,082

Re: question regarding PROC TABULATE

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.

Occasional Contributor
Posts: 8

Re: question regarding PROC TABULATE

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 


Super User
Posts: 17,828

Re: question regarding PROC TABULATE

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!

Respected Advisor
Posts: 4,646

Re: question regarding PROC TABULATE

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
Ask a Question
Discussion stats
  • 6 replies
  • 450 views
  • 0 likes
  • 4 in conversation