BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ
Hi:
I've tried the same code and got a Table of Contents. I think you need to work with Tech Support on why the code does not work for you. They'll need to look at all your code and your version info to figure out what might be wrong.
Cynthia

View solution in original post

6 REPLIES 6
Cynthia_sas
SAS Super FREQ
Hi:
In our classes we typically show how to do a right-click and then Update Field to make the Contents page populate in Word. You didn't way what word processing application you were working in. However, sometimes, in Word, it is hard to right click in the right place and find Update Field as a choice. So, there are 2 alternate methods you can use (in Word):

1) Go to the Word ribbon and click on References and then in the Table of Contents section choose Update Table and that should update the Table of Contents (assuming you used the right options to create the Table of Contents field codes);

or

2) When you are at the first page (showing the text Table of Contents), do a Ctrl+A to select the entire document and then click F9 to update the tables in the document.

Both of these methods work in Word 2016 to refresh the Table of Contents as an alternative to the right-click method we show in our courses. Your code worked for me in SAS 9.4 M5 and 9.5M6. So, if none of that works for you, then I suggest opening a track with Tech Support.

Cynthia
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

Cynthia_sas
SAS Super FREQ
Hi:
I've tried the same code and got a Table of Contents. I think you need to work with Tech Support on why the code does not work for you. They'll need to look at all your code and your version info to figure out what might be wrong.
Cynthia
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Thanks Cynthia, I thought it might come to that.  I will get hold of them at some point and go through it.

 

biopharma
Quartz | Level 8

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.

biopharma
Quartz | Level 8

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. 

SAS Innovate 2025: Register Now

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 2310 views
  • 0 likes
  • 3 in conversation