BookmarkSubscribeRSS Feed
DeepSiv
Fluorite | Level 6

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!

5 REPLIES 5
snoopy369
Barite | Level 11

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).

Peter_C
Rhodochrosite | Level 12

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

Patrick
Opal | Level 21

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', .....

DeepSiv
Fluorite | Level 6

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.

Peter_C
Rhodochrosite | Level 12

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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 5 replies
  • 823 views
  • 0 likes
  • 4 in conversation