BookmarkSubscribeRSS Feed
KimLeBouton
Quartz | Level 8
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?

TIA,
Kim LeBouton
3 REPLIES 3
Tim_SAS
Barite | Level 11
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.
Cynthia_sas
SAS Super FREQ
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.
Cynthia_sas
SAS Super FREQ
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.

cynthia

[pre]
*** code;
%macro doreg(sreg=);
ods proclabel "PROCLABEL: &sreg";
proc report data=sashelp.shoes 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;
run;
%mend doreg;

ods listing close;
ods html path='c:\temp' (url=none)
file='k_bod.html'
frame='k_frm.html'
contents='k_toc.html'
style=sasweb;

%doreg(sreg=Africa);
%doreg(sreg=Canada);
%doreg(sreg=Pacific);

ods html close;
[/pre]

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 3 replies
  • 827 views
  • 0 likes
  • 3 in conversation