Usage Note 24034: Can I append to an ODS RTF file?
It is not currently possible to append to an RTF file. This is because an RTF document consists of orderly parts. As it builds, it stores information for colors, fonts, body, header, and so on. At the close, it puts the different parts in order. Therefore, simply appending is not appropriate for the structure of an RTF document.
The sample code on the Full Code tab shows two methods for combining output into an RTF file. Method 1 shows how to use multiple RTF instances to route to more than one RTF file at a time, resulting in four files. The COMBINED.RTF file has three PROC REPORT tables, while A.RTF, B.RTF, and C.RTF each contain the results from single PROC REPORT steps. This logic might help prevent the need for appending RTF files. Method 2 shows the use of ODS and PROC DOCUMENT to combine tables into an RTF file. ODS DOCUMENT stores SAS results into an itemstore, and PROC DOCUMENT provides the ability to replay those results to any ODS destination.
See more information about
PROC TEMPLATE and the RTF destination.
Operating System and Release Information
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
The code under Method 1 uses multiple RTF instances to route to more than one RTF file at a time, resulting in four files: COMBINED.RTF has three PROC REPORT tables, while A.RTF, B.RTF, and C.RTF each contain the results from single PROC REPORT steps. The code under Method 2 shows the use of ODS and PROC DOCUMENT logic which allows us to store results into documents, and then replay those results to the open RTF destination. This code creates one RTF file: Combined_document.rtf .
/* Method 1 */
ods rtf file="combined.rtf";
ods rtf(a) file="a.rtf";
proc report nowd data=sashelp.class(obs=10);
title "In COMBINED.RTF and A.RTF";
run;
ods rtf(a) close;
ods rtf(b) file="b.rtf";
proc report nowd data=sashelp.vtable(obs=20);
title "In COMBINED.RTF and B.RTF";
column libname memname nobs nvar crdate;
run;
ods rtf(b) close;
ods rtf(c) file="c.rtf" ;
proc report nowd data=sashelp.class;
title "In COMBINED.RTF and C.RTF";
run;
ods rtf(c) close;
ods rtf close;
/* Use this shortcut to close all ODS destinations */
/* ods _all_ close; */
/* Method 2 */
libname docs '.';
ods document name=docs.test1(write);
proc report nowd data=sashelp.class(obs=10);
title "SASHELP.CLASS(obs=10)";
run;
ods document close;
/* This code can be part of a separate SAS session: */
ods document name=docs.test2(write);
proc report nowd data=sashelp.vtable(obs=20);
title "SASHELP.VTABLE(obs=20)";
column libname memname nobs nvar crdate;
run;
proc report nowd data=sashelp.cars(obs=10);
title "SASHELP.CARS(obs=10)";
run;
ods document close;
/* PROC DOCUMENT can be submitted in the same SAS session as the code above, or in a new SAS session */
libname docs ".";
ods rtf file="combined_document.rtf";
proc document name=docs.test1;
replay;
run;
quit;
proc document name=docs.test2;
replay;
run;
quit;
ods _all_ close;
Type: | Usage Note |
Priority: | low |
Topic: | SAS Reference ==> ODS (Output Delivery System) Third Party ==> Output ==> RTF
|
Date Modified: | 2009-02-20 10:51:24 |
Date Created: | 2004-06-28 12:02:22 |