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
SAS Super FREQ

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

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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