When I run an ODS RTF statement without Bodytitle, I get what I expect (the "Update Field" option in Word, for creating a Table of Contents); when I include Bodytitle, the "Update Field" option isn't available - am I missing something? (I'm using SAS 9.4)
data test;
input name $ count;
cards;
A 1
B 2
;
run;
/* without Bodytitle*/
ods rtf file='C:\temp\TEST1.rtf' contents toc_data ;
/* with Bodytitle*/
ods rtf file='C:\temp\TEST1.rtf' contents toc_data bodytitle;
proc report data=test;
column Name count;
define name/ group ;
define count /display;
run;
ods rtf close;
Got a solution from SAS Tech Support:
You can view and update the table of contents created with BODYTITLE by selecting the entire document (Ctrl+A) and pressing F9.
(it works!)
Well, let me start by saying that RTF != Word. RTF is text markup, i.e. it is text with codes which certain programs can read and interpret. When you open and RTF file in Word, Word initiates its RTF parser software, parses the file and then decides how to render the text. Now Word is maliciously bad at these types of things, press delete foro instance on a subheading and suddenly the whole document's titels change font for instance. Unless your an expert at Word it is rare to find a solution to it.
Now to your question, bodytitle - this is an option to put titles in either the title section of Word, or, with the option bodytitle, to include that text as headings in the text of the document - i.e. you don't have titles then. How does Word do its table of contents (well who knows, I sure have never worked it out), but I imagine it links the document object - checks titles and headings, and makes its best guess. Personally, I would never rely on Word to create contents tables.
One thing I can suggest you do is to open the two files, one with bodytitle and one without in a proper text editor (Notepad++ for instance), and have a look at what tagset output is being created. Find the text of the titles and you will see they either appear in different places, or have different tags surrounding the title (or both), which means the RTF parser in Word will treat these as different.
Got a solution from SAS Tech Support:
You can view and update the table of contents created with BODYTITLE by selecting the entire document (Ctrl+A) and pressing F9.
(it works!)
Yes, that is a manual step to do it. What happens when you save that file though, do you save back to RTF and possible have to do it again, or save as Word etc.
After the Control-A / F9, I saved it as a Word doc, and the TOC is there when I re-open it (don't have to do it again)
Thanks,
Dave
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.