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.
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 ********/
Hi:
In looking here at the RTF specification:
http://ftp.artifax.net/ArtRep/2.0/Help/rtf.htm#Heading45
It looks like you might have to use a number to control the levels.
Cynthia
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.
@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.
Hi:
In looking here at the RTF specification:
http://ftp.artifax.net/ArtRep/2.0/Help/rtf.htm#Heading45
It looks like you might have to use a number to control the levels.
Cynthia
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.