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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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