BookmarkSubscribeRSS Feed
niemannk
Calcite | Level 5
My code looks like this:

[pre]
filename odsout &odsout;
ods html style=sasweb path=odsout frame=result.html contents=result_content.html nogtitle;
[/pre]

then I "macro-loop" over some variables and produce various neat graphics for each of the macro variables:
[pre]
%do i=1 %to 5;
%let strategy=strat&i;
ods graphics on /
imagefmt=png
imagemap=&odsimgmap
imagename="bck"
border=off;
ods listing close;
ods html body="&strategy..html" path=odsout gpath=&gpath nogtitle;
options nolabel;
ods proclabel "&strategy";
ods layout start columns=2;
title;
ods region;
proc sgrender data=mydata
template="styles.mygraphs";
run;

ods graphics off;
ods region;
ods proclabel "";
proc report data=Fastbt_riskout_tr(obs=17)nowd;
column quantity &score;
run;
ods layout end;
%end;
ods html close
ods listing;
[/pre]

What happens in the resulting html file result.html is that it nicely creates a table of contents in the left frame, but unfortunately adds an entry in the table of content for every proc I call inside the macro loop. The result is that my table of content is far to big!
What I get is something like this:
1. strat1
2. The Report Procedure
3. strat2
4. The Report Procedure
5. stra3
[...]

What I want is:
1. strat1
2. strat2
3. strat3
4. strat4
5. strat5

Having only two proc calls and five strategies is still bearable, but when there are 100 strategies and six proc calls the Table of Contents is not very nice to look at...
7 REPLIES 7
Cynthia_sas
SAS Super FREQ
Hi:
Just as you have
[pre]
ods proclabel " ";
[/pre]

before your PROC REPORT, you can also use the CONTENTS = option to suppress the automatic PROC REPORT entry in the results window and Table of Contents in the TOC file:

[pre]
proc report data=xxx.yyy nowd contents=" ";
[/pre]

as described here:
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002473620.htm#a003072006
http://support.sas.com/kb/23/428.html (shows PRINT, but REPORT works the same way)
http://support.sas.com/kb/23/337.html (shows tabulate, but contents= also works for PRINT and REPORT -- but on the PROC statement)

If you want to streamline the ODS HTML table of contents further than you can achieve with the above techniques, then you can also modify the style template, as shown in these notes:
http://support.sas.com/kb/23/345.html
http://support.sas.com/kb/23/344.html

cynthia
niemannk
Calcite | Level 5
mhm. The documentation says that contents="" for proc report and description="" suppress an entry in the table of contents html file. In my case (SAS 9.2) it has absolutely no effect.

after
[pre]
ods html body= ...
[/pre]
I start a ods layout and then
issue a ods proclabel and the an proc sgrender. For this first graph i want a table of contents entry . Then after this I sent a proc report and a bunch of proc sqplot (you never can have enough graphical output...) All of output will display in the body and have entry in the table of contents -no matter if contents="" or description="" is written to the respective procs.

I tried to change the template to see if changes here will affect anything:
[pre]
proc template;
define style styles.sasweb2;
parent=styles.sasweb;
style ContentTitle from Index;
style ContentProcname from Index /
bullet=none;
end;
run;
[/pre]

Also here I didn't notice any changes to the table of contents (I restarted SAS a couple of times). I had difficulties to find documentation on the used style elements "ContentTitle" and "ContentProcname", maybe some magic options exists...Any ideas?
niemannk
Calcite | Level 5
What I really want is to produce one entry in the table of contents frame for each ods html body=... statement (and not for every proc call inside the body file)
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Explore the various ODS HTML statement options - you will find one that controls how the TOC is created. Also, review the CONTENTS= as well, but the TOC hyperlink text generated by SAS is quite rudimentary and crude.

You really will want to consider using a combination of one ODS HTML statement with multiple PROC invocations using WHERE and/or BY statement processing in order to generate a meaningful TOC pane/window, in my opinion.

Scott Barry
SBBWorks, Inc.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Here is some SAS-hosted support documents, supplemental to the product documentation on ODS. Suggest you bookmark this page as a favorites for future reference.

Scott Barry
SBBWorks, Inc.

Base SAS
SAS Notes and Concepts for ODS
http://support.sas.com/rnd/base/ods/templateFAQ/index.html
Cynthia_sas
SAS Super FREQ
Hi:
Every PROC call -will- generate an entry in the TOC -- unless you take other measures like CONTENTS= to deal with it. I am surprised that CONTENTS= doesn't work for ODS HTML when you're also using ODS LAYOUT. This is a question to pursue with Tech Support.

There are template methods to suppress TOC entries. What you might try is using ODS HTML3 (HTML 3.2 tags) instead of ODS HTML (HTML 4.0 tags) and see whether the HTML is different. ODS HTML3 is the original destination and it's possible that it might work different.

Another place where you have a chance to impact the output (for ODS HTML) is to modify the tagset template (tagsets.html4) that actually -generates- the TOC file. You could alter the events that are writing to the TOC file and change so that ONLY the BODY events wrote to the TOC file instead of the PROC events. This is not a trivial undertaking -- so it wouldn't be my first choice to try.

Other than that, there might be a chance that ODS DOCUMENT and PROC DOCUMENT would allow you to build the TOC structure you want. The catch here is ODS LAYOUT -- I don't know how/whether the ODS LAYOUT statements will go into the document store -- again -- this is a question for Tech Support.

And, of course, there's always the DATA step method. If you are happy with the FRAME and BODY files and your only issue is with the CONTENTS file, you can always wait until the "big" step is done and then write over the CONTENTS= file with a file of your own that has the links you want. By the time your macro is over, you should know the name of each BODY= file. The HTML that you need for the TOC is very straightforward. This would have to be the very LAST step -- after everything else is done and the "bad" CONTENTS= file was closed. Then you could write your own HTML CONTENTS= file to subsitute instead of the "bad" one.

cynthia
niemannk
Calcite | Level 5
ok, I went for the data step version and write out my own TOC. Looks good... thank you for all help!

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