Printing Sub totals using PROC TABULATE

Reply
Contributor
Posts: 50

Printing Sub totals using PROC TABULATE

Hi all

I am having the following code:

proc tab.JPG

And my report shows up like this:

report1.jpg

My requirement is that I need to print subtotals for YRMNTH field in this same report.

So ideally my report should be something like this:

report.jpg

How do I achieve this with PROC TABULATE? Any help would be greatly appreciated.

Thanks!

Super Contributor
Posts: 253

Re: Printing Sub totals using PROC TABULATE

I don't believe you could do exactly that with PROC TABULATE.  You would use PROC REPORT for that.

You could do something sort-of like that using ALL, making YRMNTH into a page expression, if that is acceptable.

tables all yrmnth, all .......;

where ..... is all of the rest of your table statement.

so the first ALL now is for the entire report, you'll get one page for that, and one page for each YRMNTH value, with a subtotal on it (put ALL wherever you want that subtotal).

Valued Guide
Posts: 2,177

Re: Printing Sub totals using PROC TABULATE

Posted in reply to snoopy369

Deepsiv,

In the days before ODS I post processed tabulate output to provide shading in totals and subtotals so I expect what you seek is possible, but surely you don't want to down the post-processing route?.

As snoopy369 has already suggested PROC REPORT has a natural way of achieving what you request. Have you had a look in the ODS Reporting Community? I expect you'll find examples there.

peterC

Respected Advisor
Posts: 4,173

Re: Printing Sub totals using PROC TABULATE

If you would provide a data step creating sample data and then a proc tabulate using this sample data there would be a very good chance that someone actually would post working and tested code doing what you ask for....

I believe you could get to something close to what you ask for by modifying your code as follows:

TABLE YRMNTH* (TYPE*CENTER*NAME*CODE ALL='TOTAL YRMNTH') ALL='TOTAL', .....

Contributor
Posts: 50

Re: Printing Sub totals using PROC TABULATE

Hi all

Thanks for your suggestions. If I use PROC REPORT, I m unable to print the row total for the amount across newcode.  I need to compute the row total for the NEWCODE variable as well. Please refer my below code:

proc report.JPG

The report appears like this: Sub total objective gets satisfied, but row total goes  missing.

report.jpg

Could someone help me with the computation for the row total of the across field? Thanks.

Valued Guide
Posts: 2,177

Re: Printing Sub totals using PROC TABULATE

I think you'll find your answer invthe ODS and Base Reporting Community

Ask a Question
Discussion stats
  • 5 replies
  • 314 views
  • 0 likes
  • 4 in conversation