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

 

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Dave25
Quartz | Level 8

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!)

 

 

View solution in original post

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

Dave25
Quartz | Level 8

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!)

 

 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.  

Dave25
Quartz | Level 8

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 3020 views
  • 0 likes
  • 2 in conversation