I am currently running this following code,
proc tabulate data=sashelp.cars;
class origin drivetrain type;
var msrp;
table (drivetrain * (N))
(msrp * (N MEAN MEDIAN MIN MAX)),
ALL origin type/ misstext='0';
run;
The current output looks something like this,
All | Origin | Type | |||||||||
Asia | Europe | USA | Hybrid | SUV | Sedan | Sports | Truck | Wagon | |||
DriveTrain | |||||||||||
All | N | 92 | 34 | 36 | 22 | 0 | 38 | 28 | 5 | 12 | 9 |
Front | N | 226 | 99 | 37 | 90 | 3 | 22 | 179 | 8 | 0 | 14 |
Rear | N | 110 | 25 | 50 | 35 | 0 | 0 | 55 | 36 | 12 | 7 |
MSRP | N | 428 | 158 | 123 | 147 | 3 | 60 | 262 | 49 | 24 | 30 |
Mean | 32774.86 | 24741.32 | 48349.8 | 28377.44 | 19920 | 34790.25 | 29773.62 | 53387.06 | 24941.38 | 28840.53 | |
Median | 27635 | 23032.5 | 40590 | 25520 | 20140 | 32062.5 | 26432.5 | 40590 | 22180 | 25545 | |
Min | 10280 | 10280 | 16999 | 10995 | 19110 | 17163 | 10280 | 18345 | 12800 | 11905 | |
Max | 192465 | 89765 | 192465 | 81795 | 20510 | 76870 | 128420 | 192465 | 52975 | 60670 |
The issue I'm facing currently is, I do not want to display columns Sedan and Sports but at the same time I do not want my over all count for Origin or All to get affected. Is it possible to achieve this by any means?
Thanks in advance! 🙂
Hello,
It has been many, many years since I have last used PROC TABULATE, so I do not know very well about the best answer.
You can have two 'table' statements of course in the same PROC TABULATE, one with ORIGIN and one with TYPE.
Or you can save the output table in an output dataset with ODS OUTPUT and work further from there.
As in:
ods trace on;
ods output table=work.table;
proc tabulate data=sashelp.cars;
...
run;
/* end of program */
You can alternatively do some base SAS programming to get what you want or maybe it is easier to do with PROC REPORT? I think in PROC REPORT it is easier to suppress columns in the display while they are still used for some of the statistics.
Koen
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.