BookmarkSubscribeRSS Feed
snoopy369
Barite | Level 11

I have a PROC TABULATE question that I need to figure out if there is a good answer to.

 

I have two class columns followed by data columns.  On the two class columns, the second includes 'all' as well as the subclass.

 

I'd like to have a column header for the second column that specifies that column's variable name or something similar, but only appears in the table header - doesn't get replicated for each set of rows.

 

This is how it would work if `all` wasn't  involved.  Since `all` is, it doesn't work - it repeats every row of the major category.

 

Here's a code sample.  This doesn't work of course.  Putting the '=Type only' bit after type makes it repeat every new Origin line.

 

I want to stick to Tabulate; I probably will just leave the subheader off entirely if this isn't possible (rather than shelling out to PROC REPORT or something).

 

proc tabulate data=sashelp.cars;
class origin type make;
var mpg_city mpg_highway;

tables origin*(type all)='Type only on first row please', 
          make*(mpg_city mpg_highway)*mean;
run;
1 REPLY 1
ballardw
Super User

If I understand what you want perhaps this is an acceptable work around by moving both column labels into the Box though this can be kludgy to get good appearance for different widths of row header columns.

proc tabulate data=sashelp.cars;
class origin type make;
var mpg_city mpg_highway;

tables origin='' *(type='' all), 
          make*(mpg_city mpg_highway)*mean
       /box='Origin Type';
run;

 

Or perhaps move to Proc report where instead of All you'd be looking at a break line for summaries.

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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