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. If it just appears on the top row of the table, that is fine with me. 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?

Tabulate Expected Output.png

Regards,

Shubha

3 REPLIES 3
Ksharp
Super User

That could not be possible . The only thing I can thing is using BOX .

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 */

/box='Region    Market    Name' ; /*INDENT=0*/

RUN;

But proc report can get it easily. OR try to post it at ODS REPORT forum . Cynthia might have a good idea.

Xia Keshan

Shubha
Calcite | Level 5

Thanks very much Xia. Will try posting at the ODS REPORT.

Regards,

Shubha

ballardw
Super User

Indicating a blank label in the table statement will suppress any label:

market='' * Name=''

BUT since you have Region appearing you'll get some empty cells at the first region value and depending on destination the values on the first row may appear at the top of the cells.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 1167 views
  • 0 likes
  • 3 in conversation