BookmarkSubscribeRSS Feed
Shubha
Calcite | Level 5

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

1 REPLY 1
Cynthia_sas
Diamond | Level 26

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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 2108 views
  • 0 likes
  • 2 in conversation