Hi,
I have noted over time that there is something peculier in the way options are handled on SAS 9.4. If I take some basic code such as this:
ods rtf file="s:\test.rtf"; options orientation=landscape; title1 "Hello"; proc print data=sashelp.cars; run; ods rtf close;
And run this in a fresh session, the rtf output is portrait, even though the options states landscape. If I run this code exactly the same again, the landscape instruction seems to take effect and the output is then landscape for that output run and all further ones within the session. If however I create a news session and run it, back to portrait for the first run only.
It seems like first run options are being set, but not used in the current run. Could someone help clarify?
I think this works if you set the options before you create the RTF file:
options orientation=landscape;
title1 "Hello";
ods rtf file="s:\test.rtf";
proc print data=sashelp.cars;
run;
ods rtf close;
Perhaps ODS RTF statement writes or remembers the options at the time that the statement is executed (the file is opened), rather than when the contents are written.
Hello,
I think this is because the options have to be set befor the ods instruction.
I think this works if you set the options before you create the RTF file:
options orientation=landscape;
title1 "Hello";
ods rtf file="s:\test.rtf";
proc print data=sashelp.cars;
run;
ods rtf close;
Perhaps ODS RTF statement writes or remembers the options at the time that the statement is executed (the file is opened), rather than when the contents are written.
@RW9 wrote:
Thanks @Rick_SAS, @gamotte, yes quite true, options after the ods do not seem to effect. Strange, sure they always used to. Anyways, will make sure the options are set before the ods in future.
@RW9 I suspect this behavior is related only the options in the ODSPRINT options group. Perhaps the other options you remember working as desired were from a different group. Or is ODSPRINT group new?
Its been a while, but I was sure we used to change orientation in outputs during runs within ods. Although looking back we probably created separate ones and combined in PDF. Anyways, simplest is to always put options at the start of a program, most are setup at system level anyways.
There are certain options that you can change while the ODS destination is open, and others that must be in place before you begin. Page Orientation makes sense (to me) as something that needs to be in place early. But other items, like the ODS STYLE or PAGENO, can be changed on the fly.
options orientation=landscape;
title1 "Hello";
ods rtf file="c:\temp\test.rtf" style=rtf;
proc print data=sashelp.cars (obs=20);
run;
options pageno=10;
ods rtf style=analysis ;
proc print data=sashelp.class;
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.