BookmarkSubscribeRSS Feed
BruceBrad
Lapis Lazuli | Level 10

I'm trying to write some tables to a RTF file, and some to an Excel sheet. After setting up the destinations I have code like the following. However, the title "Excel output 1" is appearing in the RTF output. How do I suppress this?

 

ods excel select none;
title "RTF output 1";
proc etc;
run;
ods rtf select none;
ods excel select all;
title "Excel output 1";
proc etc;
run;
6 REPLIES 6
Oligolas
Barite | Level 11

Hi,

use ods rtf close or ods excel close to stop the destination export.

use TITLE without arguments to cancel all existing titles when not needed any more.

________________________

- Cheers -

Cynthia_sas
SAS Super FREQ
Hi:
SAS Title and Footnote statements are not impacted by the ODS SELECT statements. ODS SELECT (and ODS EXCLUDE) control the output objects that are written to the the various destinations. Output objects are like the Extreme Obs table from PROC UNIVARIATE or the VARIABLES object from PROC CONTENTS. The output object is what is controlled/produced by the procedure. TITLES and FOOTNOTES are global in nature and apply to all the output being created by in a job step. If you have both ODS EXCEL and ODS RTF open at the same time, then the TITLE will get written to all the open destinations.
Cynthia
BruceBrad
Lapis Lazuli | Level 10
My understanding is that if I close a destination and then open it again, the earlier output gets overwritten. Is that correct? I can't see any option to open a spreadsheet and/or RTF in append mode. So it looks like it is not possible to do what I want (writing alternately to excel and rtf).
Cynthia_sas
SAS Super FREQ

Hi:
Your understanding is correct. ODS RTF and ODS EXCEL do not allow "appending" after the original file is closed the first time. ODS only will write over the original file name if you try to append -- the only destination that allows appending is ODS HTML. I would either use a Macro program to control what is getting written to each destination like this or I would write all the output to an ODS DOCUMENT store and then replay the objects as I chose to the different destinations. Here's a paper https://support.sas.com/resources/papers/sgf09/318-2009.pdf that describes the ODS DOCUMENT approach. Look on page 17 for a more advanced use of the REPLAY statement to replay objects to differing destinations.

Here's an example of one possible macro program approach:

possible_macro.png

Since I used STARTPAGE=NO the second title for ODS RTF would not go on the same page with the first TITLE. That's why I used ODS TEXT= to place some text before the 2nd table.

 

Cynthia

BruceBrad
Lapis Lazuli | Level 10

Thanks for this. But it seems very messy for what is a simple requirement. I'll experiment with suppressing all titles and just using ODS Text to output my titles (and format them manually in Word).

Cynthia_sas
SAS Super FREQ
Hi:
You can format the text from ODS RTF TEXT= using a STYLE template change. That method is shown in this paper on pages 11 and 12: https://support.sas.com/resources/papers/proceedings10/033-2010.pdf .

Cynthia

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1405 views
  • 4 likes
  • 3 in conversation