Supposedly I'm trying to spit out a page or two of ODS <RTF/PDF> TEXT stuffs before or after PROC REPORT/PRINT stuffs in my RTF/PDF output.
ODS LISTING CLOSE;
OPTIONS NODATE
NONUMBER
TOPMARGIN =0.5IN
LEFTMARGIN =0.5IN
RIGHTMARGIN =0.5IN
BOTTOMMARGIN=0.5IN;
/*%let ftype=PDF;*/
%let ftype=RTF;
ods noptitle;
ODS &ftype FILE = "&base\test.&ftype" STYLE=BARRETTSBLUE;
ods proclabel='Frequencies';
ODS ESCAPECHAR = '^';
ODS &ftype TEXT = "^{STYLE[FONTSIZE=22 JUST=L fontweight=bold]THIS SHOULD BE PAGE 1}";
ODS &ftype TEXT = " ";
ODS &ftype TEXT = "^{STYLE[FONTSIZE=18 JUST=L](BLAH BLAH BLAH) 1}";
ods rtf startpage=now;
ODS &ftype TEXT = "^{STYLE[FONTSIZE=22 JUST=L fontweight=bold]THIS SHOULD BE PAGE 2}";
ODS &ftype TEXT = " ";
ODS &ftype TEXT = "^{STYLE[FONTSIZE=18 JUST=L](BLAH BLAH BLAH) 2}";
ods rtf close;
quit;
title;
ODS _all_ CLOSE;
I tried using some suggestions from another posting on this forum but it seems that it doesn't work in this case as you can see below.
Any idea how I can split them to see 'THIS SHOULD BE PAGE 1" on page 1 and 'THIS SHOULD BE PAGE 2' on page 2 in my RTF or PDF output?
With RTF, not PDF, you can use the Raw function to insert raw RTF codes, such as a new page (you'll have to look up the RTF codes on your own).
My experience with ODS TEXT is that without procedure output following it you often don't get any ODS TEXT result at all.
Sometime you have to use multiple ODS destinations with the equivalent of STARTPage= no; then Startpage=now. The two together force and end of page and then new page. I say equivalent because not all ODS destinations use the same approach to pagination.
There have been a few times that it seemed like code using Escapechar and style elements with ODS TEXT behaved a little differently if the ODS ESCAPECHAR statement came before the ODS destination statement, but I don't have an example to hand at the moment. You may want to try that if the ODS TEXT misbehaves.
And instead of
ODS &ftype TEXT = " ";
you might want to try using the NEWLINE function in the previous statement
ods rtf file='c:\temp\want.rtf' style=journal;
ODS ESCAPECHAR = '^';
ODS rtf TEXT = "^{STYLE[FONTSIZE=22 JUST=L fontweight=bold]THIS SHOULD BE PAGE 1}";
ODS rtf TEXT = " ";
ODS rtf TEXT = "^{STYLE[FONTSIZE=18 JUST=L](BLAH BLAH BLAH) 1}";
data _x_;
x='09'x;
run;
proc report data=_x_ nowd style={rules=none frame=void} noheader;
run;
proc report data=sashelp.class nowd;run;
proc report data=_x_ nowd style={rules=none frame=void} noheader;
run;
ODS rtf TEXT = "^{STYLE[FONTSIZE=22 JUST=L fontweight=bold]THIS SHOULD BE PAGE 2}";
ODS rtf TEXT = " ";
ODS rtf TEXT = "^{STYLE[FONTSIZE=18 JUST=L](BLAH BLAH BLAH) 2}";
proc report data=sashelp.class nowd;run;
ods rtf close;
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.