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

I am working on a document that I want to give an extensive ToC. I have used the information at https://support.sas.com/resources/papers/proceedings/proceedings/forum2007/097-2007.pdf to generate one using ODS RTF and \tc RTF tags. Everything is working fine except I would like to add levels to it (tabbed over). As you can see in my picture below, there are section headings and then subsections. I assume this can be accomplished by altering the template for different heading levels, but I'm not quite sure how to execute that. I'm using PROC ODSTEXT for the actual text in the document and tried to just apply H1 and H2 where I wanted the leveling, but this did not work.

 

toc_ex.png

Code sample for style template and first section and subsection:

/* define document template */
proc template; 
define style styles.drtf; 
parent= styles.rtf; 
style fonts / 
'TitleFont2' = ("Arial",12pt,bold italic) 
'TitleFont' = ("Arial",13pt,bold italic) 
'StrongFont' = ("Arial",10pt,bold) 
'EmphasisFont' = ("Arial",10pt,italic) 
'FixedEmphasisFont' = ("Arial",9pt,italic) 
'FixedStrongFont' = ("Arial",9pt,bold) 
'FixedHeadingFont' = ("Arial",9pt,bold) 
'BatchFixedFont' = ("Arial",6.7pt) 
'FixedFont' = ("Arial",9pt) 
'headingEmphasisFont' = ("Arial",11pt,bold italic) 
'headingFont' = ("Arial",11pt,bold) 
'docFont' = ("Arial",10pt); 
class GraphFonts / 
'NodeDetailFont' = ("Arial",7pt) 
'NodeInputLabelFont' = ("Arial",9pt) 
'NodeLabelFont' = ("Arial",9pt) 
'NodeTitleFont' = ("Arial",9pt) 
'GraphDataFont' = ("Arial",8pt) 
'GraphUnicodeFont' = ("<MTserif-unicode>",9pt) 
'GraphValueFont' = ("Arial",10pt) 
'GraphLabel2Font' = ("Arial",11pt) 
'GraphLabelFont' = ("Arial",11pt) 
'GraphFootnoteFont' = ("Arial",11pt) 
'GraphTitleFont' = ("Arial",12pt,bold) 
'GraphTitle1Font' = ("Arial",15pt,bold) 
'GraphAnnoFont' = ("Arial",10pt);
style color_list 
"Colors used in the default style" / 
'link' = blue 
'bgH' = grayBB 
'fg' = &DBlack. 
'bg' = _undef_; 
class Heading1 / 
foreground = &DBlack.
fontfamily = "Arial";
style header from header /protectspecialchars=off;
style data from data /protectspecialchars=off;
style rowheader from rowheader / protectspecialchars=off;
style systemtitle from systemtitle /protectspecialchars=off;
style systemfooter from systemfooter /protectspecialchars=off;
style usertext from usertext /protectspecialchars=off OutputWidth = 100%;
style byline from byline /protectspecialchars=off; 
end; 
run;
ods rtf file="&path.\Summary Report\summary_report_1920.rtf" 
	nogtitle nogfootnote style=styles.drtf notoc_data;
goptions reset=all;
ods noresults; 

/* sensitive content removed */

/* page 3 */
proc odstext pagebreak=yes;
	h "{\scaps Contents}" / style={fontfamily='Arial' fontweight=bold font_size=12pt just=c};
run;

ODS RTF TEXT="{\field{\*\fldinst {\\TOC \\f \\h} } }"; RUN; 

/* Section I */
proc odstext pagebreak=yes;
	h1 "^20n {\tc {\scaps I. Introduction & Methodology}}" / style={fontfamily='Arial' fontweight=bold font_size=12pt just=c};
run;

/* Section I Content */
proc odstext pagebreak=yes;
	h2 "{\tc {\scaps 1.1 Project Overview}}" / style={fontfamily='Arial' fontweight=bold font_size=10pt just=l};
	p ;
	p "stuff" / style={fontfamily='Arial' font_size=10pt foreground=&Dblack.};
run;

/* close rtf */
ods rtf close;
ods html;
ods graphics on / reset;
ods results;
/******** end rtf document ********/

 

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
Diamond | Level 26

Hi:

  In looking here at the RTF specification:

http://ftp.artifax.net/ArtRep/2.0/Help/rtf.htm#Heading45

 

rtf_tc_spec.png

 

It looks like you might have to use a number to control the levels.

 

Cynthia

View solution in original post

8 REPLIES 8
ballardw
Super User

As a minimum show the code used.

Sometimes issues just need minor tweaks to code. Sometimes your code may have specified options that prevent something. But to tell which we need to see the code.

Better would be to post a small example of any data sets used if needed in the form of data step code so we can test code with actual data.

 

Post code in a code box opened on the forum using either the </> or "running man" icon to prevent the main message windows from reformatting your code and possibly inserting HTML tags that might mean the code posted is not what you have actually attempted.

Cynthia_sas
Diamond | Level 26
Hi:
Do you mean PRETEXT, not PROTEXT? That was a user-submitted paper and is 13 years old. It was probably SAS 9.1 or 9.2 version of ODS RTF. This might be a question for either Tech Support, because they can look at ALL of your code and all of your RTF controls and see whether they have a solution or workaround based on what version of SAS you're using or you might try to contact the paper author to see what her suggestions are.
Cynthia
tburus
Obsidian | Level 7
Wow! How did I not catch that typo? It should be PROC ODSTEXT (fixed in original now).

I know that's an old paper, but I cannot find anything with differing information for 9.4 or greater, so I figure it's still good. And it works. The author doesn't give any input on how to add levels their self, so it's not an issue of bad code, just one of not knowing how to add further code to get what I want.
ballardw
Super User

@tburus wrote:
Wow! How did I not catch that typo? It should be PROC ODSTEXT (fixed in original now).

I know that's an old paper, but I cannot find anything with differing information for 9.4 or greater, so I figure it's still good. And it works. The author doesn't give any input on how to add levels their self, so it's not an issue of bad code, just one of not knowing how to add further code to get what I want.

Which is why sharing your current cod is a good idea.

tburus
Obsidian | Level 7
I have edited to include relevant code. Thanks.
Cynthia_sas
Diamond | Level 26

Hi:

  In looking here at the RTF specification:

http://ftp.artifax.net/ArtRep/2.0/Help/rtf.htm#Heading45

 

rtf_tc_spec.png

 

It looks like you might have to use a number to control the levels.

 

Cynthia

tburus
Obsidian | Level 7
That seems to be what I want, but when I apply it as "\tcl1", the "l 1" goes into the document and the "\tc" part gets ignored. Is there possibly something I need to do to let the system know I am using the longer tag? I'm not super familiar with RTF tags or their documentation.
tburus
Obsidian | Level 7
Nevermind. I have to add both the \tc and the \tcl1 tags. Thanks.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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