The SAS Output Delivery System and reporting techniques

PROC TABULATE: specifying column header for only first row

Reply
Super Contributor
Posts: 311

PROC TABULATE: specifying column header for only first row

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;
Super User
Posts: 11,793

Re: PROC TABULATE: specifying column header for only first row

Posted in reply to snoopy369

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.

Ask a Question
Discussion stats
  • 1 reply
  • 102 views
  • 0 likes
  • 2 in conversation