Sunday, December 6, 2009

Dressing Up PROC REPORT

or PRINT, or FREQ or TABULATE, or . . . . far be it from me to re-start SAS PROC reporting wars ;-).

So lets say you have lots of reporting programs that you would like to make available on the SAS Portal. Since you already have SAS code and data to produce all the reports, you don't want to have to recreate them all using, for example, Web Report Studio (WRS).

But yet you do need/want some of the cool features that you've seen WRS can do, e.g.,
  • frozen column headers as you scroll
  • sorting the table on any column
  • and so on, and so on. . . .

One solution to this is to use the SAS TableEditor tagset.

The following simple program (which is run as a Stored Process) which summarizes/groups the data demonstrates this. Use the above link to find out what the various TableEditor options in the ods statement do. And, of course, there are lots, lots more options that that do all sorts of kewl things.



ods tagsets.tableeditor file = _webout
options(sort="yes" pageheight="300" pagewidth="490"
background_color="white"
frozen_headers="yes" frozen_rowheaders="yes");

proc report data = sashelp.shoes nowd
style(column) = [font_size=9pt]
style(header) = [font_size=9pt];
columns Region Stores Sales Inventory Returns;
define Region / group style(Header) = [tagattr="type='String'"];
define _numeric_ / sum style(Header) = [tagattr="type='Numberx'"];
footnote h=1 j=left 'Click on the Column Header to Sort the Rows in the Table';
run;
ods tagsets.tableeditor close;



Give it a test run on my server if you want to see this in action on the SAS Portal.

My next few posts will talk about how to package code like this using the macro facility in order to make it easy to run them as stored processes. I'll also talk about some other things you can do to make the code a bit glitzier.

No comments:

Post a Comment