04-11-2012 02:17 PM
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 ?
INPUT Name $ 1-12 Port $ 14-20 Locomotion $ 22-26 Type $ 28-30
* PROC TABULATE report with options;
PROC TABULATE DATA = boats FORMAT=DOLLAR9.2;
CLASS Locomotion Type;
TABLE Locomotion ALL, MEAN*Price*(Type ALL) <=====================================
/BOX='Full Day Excursions' MISSTEXT='none';
Input data for above is given below.
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
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.
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
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!
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.