Sample 49741: Automate writing titles and footnotes to the first and last pages in the RTF document using the macro facility and ODS TEXT statements
ODS TEXT statements can be used instead of TITLE and FOOTNOTE statements to place text in the body of an RTF document. This is a technique illustrated in Sample 49731.
In the sample code on the Full Code tab, we use macro processing to automate the process of writing the text as titles and footnotes on the first and last pages of an RTF document.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
When using a TITLE and FOOTNOTE statement in the ODS TAGSETS.RTF destination (or when using the BODYTITLE option in traditional ODS RTF), the titles and footnotes are written to the body of the document before and after tables on every page. In this sample, the text strings reside in data sets. Macros are used before and after PROC REPORT statements to write the strings as titles and footnotes to the first and last pages of the RTF file. A style template is created to format the strings like titles and footnotes.
/* Clear existing titles and footnotes */
title1;
title2;
footnote1;
footnote2;
/* Remove the date and page number */
options nodate nonumber;
/* Set the escape character and use ^n to position text strings */
ods escapechar='^';
/* Create a title and footnote data set. */
/* Create a unique macro variable for each line of text in the file. */
data titles;
input text $100.;
infile datalines4 truncover eof=last ;
call symputx('t'||strip(_n_),text);
last:
call symputx('total',(_n_-1));
datalines4;
"This is my Title"
"This is my second Title^5n";
;;;;
run;
data footnotes;
infile datalines4 truncover eof=last;
input text $100.;
call symputx('f'||strip(_n_),text);
last:
call symputx('totalf',(_n_ -1));
datalines4;
"^12n This is my first Footnote"
"This is my second Footnote";
;;;;
run;
/* Create macros to automate ODS TEXT statements. */
/* Use ODS TAGSETS.RTF TEXT= to get single spacing of titles. */
/* Change ODS TAGSETS.RTF TEXT= to ODS RTF TEXT= when writing to the traditional ODS RTF destination. */
%macro titles;
%do i=1 %to &total;
ods tagsets.rtf text=&&t&i;
%end;
%mend titles;
%macro footnotes;
%do i=1 %to &totalf;
ods tagsets.rtf text=&&f&i;
%end;
%mend footnotes;
/* Format text strings by defining a style template */
proc template;
define style styles.demo;
parent=styles.rtf;
class UserText from Note /
font_weight=bold
font_size=22pt
foreground=red
just=c
outputwidth=100%
;
end;
run;
/* Uncomment the line below for the traditional ODS RTF destination */
/*ods rtf file="c:\testrtf.rtf" style=styles.demo bodytitle;*/
/* Create the RTF file and place text on the first and last pages */
ods tagsets.rtf file="test.rtf" style=styles.demo;
%titles;
proc report data=sashelp.class nowd;
proc report data=sashelp.class nowd;
proc report data=sashelp.class nowd;
run;
%footnotes;
ods _all_ close;
|
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
This sample uses macro processing to simplify coding ODS TEXT statements to put titles and footnotes on the first and last pages within the body of the RTF document.
Date Modified: | 2014-10-24 10:18:25 |
Date Created: | 2013-04-24 21:16:50 |
Operating System and Release Information
SAS System | Base SAS | z/OS | 9.3 TS1M2 | |
Z64 | 9.3 TS1M2 | |
Microsoft® Windows® for x64 | 9.3 TS1M2 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.3 TS1M2 | |
Microsoft Windows Server 2003 Enterprise Edition | 9.3 TS1M2 | |
Microsoft Windows Server 2003 Standard Edition | 9.3 TS1M2 | |
Microsoft Windows Server 2003 for x64 | 9.3 TS1M2 | |
Microsoft Windows Server 2008 | 9.3 TS1M2 | |
Microsoft Windows Server 2008 for x64 | 9.3 TS1M2 | |
Microsoft Windows XP Professional | 9.3 TS1M2 | |
Windows 7 Enterprise 32 bit | 9.3 TS1M2 | |
Windows 7 Enterprise x64 | 9.3 TS1M2 | |
Windows 7 Home Premium 32 bit | 9.3 TS1M2 | |
Windows 7 Home Premium x64 | 9.3 TS1M2 | |
Windows 7 Professional 32 bit | 9.3 TS1M2 | |
Windows 7 Professional x64 | 9.3 TS1M2 | |
Windows 7 Ultimate 32 bit | 9.3 TS1M2 | |
Windows 7 Ultimate x64 | 9.3 TS1M2 | |
Windows Vista | 9.3 TS1M2 | |
Windows Vista for x64 | 9.3 TS1M2 | |
64-bit Enabled AIX | 9.3 TS1M2 | |
64-bit Enabled HP-UX | 9.3 TS1M2 | |
64-bit Enabled Solaris | 9.3 TS1M2 | |
HP-UX IPF | 9.3 TS1M2 | |
Linux | 9.3 TS1M2 | |
Linux for x64 | 9.3 TS1M2 | |
Solaris for x64 | 9.3 TS1M2 | |