The SAS Output Delivery System and reporting techniques

Proc Tabulate with SubTotals - Column Headings

Reply
Occasional Contributor
Posts: 11

Proc Tabulate with SubTotals - Column Headings

Hi,

 

I want the class headings of proc tabulate to appear only once on the top row of the table when the sub-totals are requested for. Currently, they appear right after each of the sub-totals which is not I am expecting for my table. I only need the headings appearing only once in the top row. I tried INDENT=0 option but it removes all the class headings. Any ways to do this?

 

Below, I give a small piece of code to test.

 

data dat;

input Region $ Market $ Name $ Volume;

cards;

A A1 X 12

A A2 Y 65

B B1 M 34

B B2 N 24

C C1 P 14

C C2 Q 42

;

run;

 

PROC TABULATE DATA=WORK.DAT;

VAR Volume;

CLASS Region / ORDER=UNFORMATTED MISSING;

CLASS Market / ORDER=UNFORMATTED MISSING;

CLASS Name / ORDER=UNFORMATTED MISSING;

TABLE

/* Row Dimension */

  Region*(

  Market*

  Name

  ALL={LABEL="Total Market"}),

 

/* Column Dimension */

Volume*

  Sum

 

/*Table Options */

  / ; /*INDENT=0*/

  ;

  RUN;

  RUN; QUIT;

        

I need the output as below. Can this be done in Proc tabulate?

Image.png

SAS Super FREQ
Posts: 8,745

Re: Proc Tabulate with SubTotals - Column Headings

Hi:

  If you switch to PROC REPORT, you can get output that is closer to what you want. Please see the attached code and screen shot.

cynthia

 

** code;

data dat;
length region $15;
input Region $ Market $ Name $ Volume;
cards;
A A1 X 12
A A2 Y 65
B B1 M 34
B B2 N 24
C C1 P 14
C C2 Q 42
;
run;

 

title; footnote;

options nodate nonumber;


ods pdf file='c:\temp\proc_report_example.pdf' style=printer;


proc report data=work.dat nowd
  style(summary)=Header;
  column region market name volume;
  define region / order style=Header;
  define market / order style=Header;
  define name / order style=Header;
  define volume / sum f=5.1;
  break after region / summarize;
  compute after region;
    region = 'Total Market';
  endcomp;
run;
ods pdf close;

 

** screen shot;

pdf_output_created_PROC_REPORT.png

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