Odd Bug in SAS 9.4 regarding options not being changed in first run

Accepted Solution Solved
Reply
Highlighted
Super User
Super User
Posts: 8,634
Accepted Solution

Odd Bug in SAS 9.4 regarding options not being changed in first run

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?


Accepted Solutions
Solution
a week ago
SAS Super FREQ
Posts: 3,907

Re: Odd Bug in SAS 9.4 regarding options not being changed in first run

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.

 

View solution in original post


All Replies
Super Contributor
Posts: 276

Re: Odd Bug in SAS 9.4 regarding options not being changed in first run

Hello,

 

I think this is because the options have to be set befor the ods instruction.

Solution
a week ago
SAS Super FREQ
Posts: 3,907

Re: Odd Bug in SAS 9.4 regarding options not being changed in first run

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.

 

Super User
Super User
Posts: 8,634

Re: Odd Bug in SAS 9.4 regarding options not being changed in first run

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.

Super User
Posts: 12,148

Re: Odd Bug in SAS 9.4 regarding options not being changed in first run


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?

Super User
Super User
Posts: 8,634

Re: Odd Bug in SAS 9.4 regarding options not being changed in first run

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.

Community Manager
Posts: 3,191

Re: Odd Bug in SAS 9.4 regarding options not being changed in first run

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;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 90 views
  • 4 likes
  • 5 in conversation