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?
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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.