The SAS Output Delivery System and reporting techniques

PROC REPORT & More Control of TOC

Posts: 52

PROC REPORT & More Control of TOC

I have a detailed PROC REPORT and would like to see if I can better control of the TOC.

I've found the ODS PROCLABEL, which is on the right track, but not detailed enough for my needs.

I'm using an RBREAK for a classification variable, and I'd like to have each RBREAK produce a TOC entry. Is it possible and has it been documented anywhere?

Kim LeBouton
Super Contributor
Posts: 394

Re: PROC REPORT & More Control of TOC

In theory you should be able to do this with a combination of RBREAK BEFORE /PAGE and the CONTENTS= option. However, CONTENTS= is pretty much broken in 9.1.3. Tech. Support and I have been discussing how PROC REPORT should handle TOC entries and I hope to give it some useful behavior in 9.2.
Posts: 8,743

Re: PROC REPORT & More Control of TOC

Theoretically, you could also wrap your PROC REPORT into a SAS macro program and then use ODS PROCLABEL for the group being passed to the macro. So, each run of the macro program would put an entry into the TOC. This is a workaround but might work, depending on the other requirements of your PROC REPORT process.
Posts: 8,743

Re: PROC REPORT & More Control of TOC

Here's a sample of the basic macro program. Playing with PROCLABEL and/or CONTENTS= you can sort of control or eliminate items in the TOC, but as somebody said, it is a kind of hit and miss affair (eliminating ODS PROCLABEL gives you an index number, with a line feed and the region on the next line; while eliminating the CONTENTS= will give you the PROCLABEL line, but no hyperlink to the section of the report associated with the region.)

In most instances, I would recommend PROC DOCUMENT/ODS DOCUMENT for rearranging your output objects and your TOC on replay, but PROC REPORT does not play nice with ODS DOCUMENT (or vice versa).

There are some style template things you can also do to streamline the TOC (playing with IndexItem, etc).

Another alternative is to replace the SAS-generated TOC file with your own TOC/Frame file if you're doing HTML. If you're doing RTF, I think some folks use RTF control strings to insert TOC info into the RTF file for TOC generation.


*** code;
%macro doreg(sreg=);
ods proclabel "PROCLABEL: &sreg";
proc report nowd
contents="Contents= &sreg";
where region = "&sreg";
title "Report for &sreg";
column subsidiary product sales;r
define subsidiary /group;
define product /group;
define sales /sum;
rbreak after /summarize;
%mend doreg;

ods listing close;
ods html path='c:\temp' (url=none)


ods html close;
Ask a Question
Discussion stats
  • 3 replies
  • 3 in conversation