Help using Base SAS procedures

Class headings of Proc Tabulate

Reply
Occasional Contributor
Posts: 11

Class headings of Proc Tabulate

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

Super User
Posts: 10,041

Re: Class headings of Proc Tabulate

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

Occasional Contributor
Posts: 11

Re: Class headings of Proc Tabulate

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

Regards,

Shubha

Super User
Posts: 11,343

Re: Class headings of Proc Tabulate

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.

Ask a Question
Discussion stats
  • 3 replies
  • 217 views
  • 0 likes
  • 3 in conversation