BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Dear All,

I had difficulty creating a 2-D table using proc tabulate:

________________I_______________II_____________________ALL____

ALL____________N_______________N____________________N_______

COMP(b)_______N_(COLPCTN)____N_(COLPCTN)_____N_(COLPCTN)___

DSC
1___________N_(COLPCTN)_____N_(COLPCTN)_____N_(COLPCTN)___
2___________N_(COLPCTN)_____N_(COLPCTN)_____N_(COLPCTN)___
....
6___________N_(COLPCTN)_____N_(COLPCTN)_____N_(COLPCTN)___

Say 'comp' is a class, it has two categories 'a' and 'b'. Under category 'a' there is another class called 'dsc' which has 6 categories. The table will include summary(N, COLPCTN) for category 'b' in 'comp' in one row, and it also include summary for each subgroup in 'dsc' but not the summary for 'a' in 'comp' in following rows. How to do the table operation to achieve this? And is there any way to put N and COLPCTN in the same cell with a parenthesis around COLPCTN?

Thanks.
1 REPLY 1
ChrisNZ
Tourmaline | Level 20
Something like this?
[pre]data MIMIC;
set SASHELP.PRDSALE(where=(PRODUCT ne 'SOFA'));
proc format;
value $prodtyp (default=12) 'BED' =' FURNITURE';
proc tabulate order=formated;
class PRODUCT COUNTRY;
table all PRODUCT='', COUNTRY*(n colpctn)*f=comma8.0;
format PRODUCT $prodtyp.;
run;
[/pre]
Only one stat per cell in the tabulate procedure.
Since you only want only one left-hand class column, you must choose between displaying 2 variables in a row
[pre]table all PRODTYPE='' PRODUCT=''[/pre]which requires massaging the data before hand,
or displaying one variable and masking it by using a format, which I did.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 896 views
  • 0 likes
  • 2 in conversation