Having some difficulties. Cannot seem to create a Table Of Contents at all on output to RTF and cannot see why. So an example:
Using SAS 9.4 1M2:
ods rtf file="afile.rtf" contents toc_data; title "First output"; proc print data=sashelp.class; run; title "Second output"; proc print data=sashelp.class; run; ods rtf close;
This produces a file, first page is Table of Contents, blank. Then the two outputs. I have tried every which way I can think of but nothing creates a table of contents. I have tried:
ods text
ods proclabel
^r/rtf's1' with wordstyle='(\s1 Heading 1;)';
I have tried with toc_data, notoc_data, keepn startpage options. Tried with render procedure, within render procedure give it an object name. Nothing seems to create a TOC when output to RTF.
Note that the above code does work if it is pdf destination (albeit without links), not rtf. I am at a loss as to why I cannot create RTF TOC's at all, am I missing some component needed for it?
Hi @Cynthia_sas , thanks for your response. I have tried these options. Using Office16, it doesn't find any table of contents. This is what is so bizarre. It creates a page one, with title Table of Contents, but there is nothing on it. Update table tells me there is no table of contents entries found.
Just doesn't seem to be writing any TOC information when RTF destination is present, and yet switch it to PDF and TOC is there fine, and bookmarks. Its like a component is missing for the RTF tagset. I have also tried with:
ods tagsets.rtf file=... options(contents='yes' data='yes');
Again, no TOC.
Thanks Cynthia, I thought it might come to that. I will get hold of them at some point and go through it.
I ran your code and I do see a TOC collapsed in the RTF. It is just not as apparent as in the Results window where you clearly see a downward arrow. You have to right click by placing the cursor BELOW the Table of Contents area and choose Update field. Not a very desirable behavior but it is expected. For more on this see: https://documentation.sas.com/?docsetId=odsug&docsetTarget=p1vvsv8ucnjzjnn1wq5wrlp74mdb.htm&docsetVe...
See Example 1 and scroll a bit down to the end of the example.
Oops. Looks like Cynthia has already posted a reply. I tried reloading the page to see if it was already answered but I didn't see any. Lo and behold when I posted the other replies appeared.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.