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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 545 views
  • 0 likes
  • 2 in conversation