It is well known that the rtf style shipped with SAS software does not meet requirements in clinical trial industry. To have more control over the look of our output, we need to create our own style. This article will show you how to modify the colors, fonts, margins, and so forth using PROC TEMPLATE and fix an issue about table lines.

The ODS TAGSETS.RTF syntax is available for SAS 9.2 and later version. Using the RTF Tagset with the ODS Markup destination enables many controls and customizations that traditional ODS RTF destination does not support. Therefore, all the examples presented in this article will apply ODS TAGSETS.RTF.

Get book with Basic knowledge

You can skip this part if you already have been familiar with ODS output system. Here is where you can find the book covering all the basic required knowledge about ODS. The hyperlink will take you to a webpage similar to that in the left panel of Figure 1. By clicking on PDF in red box, the web browser will be triggered to download pdf file and open it. Just like what you can see in the right panel of Figure 1. You can save the file into your local computer by clicking on the save icon in red box.

Here we will only have discussion on how to browse templates and find the source code for a specific template. The style templates supplied by SAS are stored in the SASHELP.TMPLMST.

This code snippet can list all templates in styles.

Click here to hide/show code

proc template ; list styles; quit;

This code snippet can make SAS display the source code of the STYLES.RTF to the log.

Click here to hide/show code

proc template ; source styles.rtf; quit;

RTF output using SAS shipped STYLES.RTF

Rather than trying to explain all of the statements and syntax required for the customization of the template, let’s look at how the RTF output will look if we use default STYLES.RTF template. Below box and Figure 2 shows the corresponding code and output. You will realize right now the default RTF style looks different from that required by clinical trial.

Click here to hide/show code

ods escapechar=”~” ;
options orientation=landscape nodate nonumber noquotelenmax;
options formchar=”|—-|+|—+=|-/\<>*”;
ods path sasuser.templat sashelp.tmplmst;
ods tagsets.rtf file=”D:/test.rtf” uniform style=styles.rtf nogtitle nogfootnote device=ACTXIMG
options(vspace = “NO”);

title1 “Sample Title”;
footnote1 “Sample Footnote”;

proc report data=sashelp.class(where=(sex = “F”));
quit;

ods tagsets.rtf close;


Standard RTF output in Clinical Trial

There are a lot of essential elements such as colors, fonts, margins that are needed to be modified. Following box will show you full code and corresponding comments. After submitting following code, we can get output like that in the top panel of Figure 3.

Click here to hide/show code

ods path fmt.customrtf(write) sasuser.templat(read) sashelp.tmplmst(read);

proc template;
define style customrtf;
parent = Styles.RTF;

replace fonts /
‘TitleFont’ = (“Times New Roman”,9pt) /* Titles from TITLE statements */
‘TitleFont2’ = (“Times New Roman”,9pt) /* Procedure titles */
‘StrongFont’ = (“Times New Roman”,9pt,Bold)
‘EmphasisFont’ = (“Times New Roman”,9pt)
‘headingEmphasisFont’ = (“Times New Roman”,9pt,Bold)
‘headingFont’ = (“Times New Roman”,9pt) /* Table column and row headings */
‘docFont’ = (“Times New Roman”,9pt) /* Data in table cells */
‘footFont’ = (“Times New Roman”,9pt) /* Footnotes from FOOTNOTE statements */
‘FixedEmphasisFont’ = (“Times New Roman”,9pt)
‘FixedStrongFont’ = (“Times New Roman”,9pt,Bold)
‘FixedHeadingFont’ = (“Times New Roman”,9pt,Bold)
‘BatchFixedFont’ = (“Times New Roman”,9pt)
‘FixedFont’ = (“Times New Roman”,9pt)
;

replace color_list /
‘link’ = blue /* links */
‘bgH’ = _undef_ /* row and column header background */
‘fg’ = black /* text color */
‘bg’ = _undef_; /* page background color */

replace Body from Document /
topmargin = 1.18 in
bottommargin = 1 in
leftmargin = 1 in
rightmargin = 1.18 in
protectspecialchars = off
;

replace Table from Output /
frame = hsides /* outside borders: void, box, above/below, vsides/hsides, lhs/rhs */
rules = groups /* internal borders: none, all, cols, rows, groups */
cellpadding = 0pt /* the space between table cell contents and the cell border */
cellspacing = 0pt /* the space between table cells, allows background to show */
borderwidth = 0.5pt /* the width of the borders and rules */
outputwidth = 100%
;

style parskip /
fontsize = 0pt
;

end;
run;

ods escapechar=”~” ;
options orientation=landscape nodate nonumber noquotelenmax;
options formchar=”|—-|+|—+=|-/\<>*”;
ods path fmt.customrtf sasuser.templat sashelp.tmplmst;
ods tagsets.rtf file=”D:/test.rtf” uniform style=customrtf nogtitle nogfootnote device=ACTXIMG
options(vspace = “NO”);

title1 justify=c “Sample Title” ;
title2 justify=l ” ” ;
title3 justify=l “Sample Treatment” ;
footnote1 justify=l ” “;
footnote2 justify=l “Sample Footnote”;

proc report data=sashelp.class(where=(sex = “F”));
quit;

ods tagsets.rtf close;


Most of the times, we need to zoom out to review more of the page at a reduced size or even more pages at the same time. If we click the Zoom slider on the status bar and slide to a smaller percentage zoom setting like 80%, you will find that the bottom line disappears. Unfortunately, this is not allowed and we need to fix the issue.

Another approach to display top and bottom line

This code snippet can prevent the table to display frame line.

Click here to hide/show code

replace Table from Output /
frame = void /* outside borders: void, box, above/below, vsides/hsides, lhs/rhs */

This section in the last title statement can draw the above line. “\brdrb\brdrs\brdrw14” are control word in RTF.

Click here to hide/show code

title3 justify=l “~R/RTF’\brdrb\brdrs\brdrw14 Sample Treatment” ;

Here is how you can draw the below line.

Click here to hide/show code

footnote1 justify=l “\brdrt\brdrs\brdrw14 “;

Click here to hide/show code

ods path fmt.customrtf(write) sasuser.templat(read) sashelp.tmplmst(read);

proc template;
define style customrtf;
parent = Styles.RTF;

replace fonts /
‘TitleFont’ = (“Times New Roman”,9pt) /* Titles from TITLE statements */
‘TitleFont2’ = (“Times New Roman”,9pt) /* Procedure titles */
‘StrongFont’ = (“Times New Roman”,9pt,Bold)
‘EmphasisFont’ = (“Times New Roman”,9pt)
‘headingEmphasisFont’ = (“Times New Roman”,9pt,Bold)
‘headingFont’ = (“Times New Roman”,9pt) /* Table column and row headings */
‘docFont’ = (“Times New Roman”,9pt) /* Data in table cells */
‘footFont’ = (“Times New Roman”,9pt) /* Footnotes from FOOTNOTE statements */
‘FixedEmphasisFont’ = (“Times New Roman”,9pt)
‘FixedStrongFont’ = (“Times New Roman”,9pt,Bold)
‘FixedHeadingFont’ = (“Times New Roman”,9pt,Bold)
‘BatchFixedFont’ = (“Times New Roman”,9pt)
‘FixedFont’ = (“Times New Roman”,9pt)
;

replace color_list /
‘link’ = blue /* links */
‘bgH’ = _undef_ /* row and column header background */
‘fg’ = black /* text color */
‘bg’ = _undef_; /* page background color */

replace Body from Document /
topmargin = 1 in
bottommargin = 1 in
leftmargin = 1 in
rightmargin = 1 in
protectspecialchars = off
;

replace Table from Output /
frame = void /* outside borders: void, box, above/below, vsides/hsides, lhs/rhs */
rules = groups /* internal borders: none, all, cols, rows, groups */
cellpadding = 0pt /* the space between table cell contents and the cell border */
cellspacing = 0pt /* the space between table cells, allows background to show */
borderwidth = 0.5pt /* the width of the borders and rules */
outputwidth = 100%
;

replace NoteContent from NoteContent /
protectspecialchars = off
asis = on
just = left
;

style Footer from Footer /
protectspecialchars = off
asis = on
just = left
;

replace Header from Header /
protectspecialchars = off
asis = on
just = left
;

replace Data from Data /
protectspecialchars = off
asis = on
;

style parskip /
fontsize = 0pt
;

end;
run;

ods escapechar=”~” ;
options orientation=landscape nodate nonumber noquotelenmax;
options formchar=”|—-|+|—+=|-/\<>*”;
ods path fmt.customrtf sasuser.templat sashelp.tmplmst;
ods tagsets.rtf file=”D:/test.rtf” uniform style=customrtf nogtitle nogfootnote device=ACTXIMG
options(vspace = “NO” watermark = “\v”);

title1 justify=c “Sample Title” ;
title2 justify=l ” ” ;
title3 justify=l “~R/RTF’\brdrb\brdrs\brdrw14 Sample Treatment” ;
footnote1 justify=l “\brdrt\brdrs\brdrw14 “;
footnote2 justify=l “Sample Footnote”;

proc report data=sashelp.class(where=(sex = “F”));
quit;

ods tagsets.rtf close;


By submitting above code, you will get an output like below in Figure 4. You can see that the bottom line still exists even if you zoom out the file.