1

Using ODS pdf I want to switch the orientation of my pdf to landscape. Unfortunately by using the options orientation=LANDSCAPE function, I have to run my code twice. After the first run the pdf is still in portrait mode.

here is some test code:

ods pdf file="C:/temp/File3.pdf";

options orientation=portrait;

proc print data=sashelp.class;
run;

proc print data=sashelp.retail;
run;

ods pdf close;

After running it I changed the orientation to landscape and run the code again, but the output is still in portrait orientation. If I run it again the option is applied and the pdf is finally in landscape mode. Is there something in this example that I should be doing different to make this work in a single pass?

For context, my reports require enough time to generate that I need to avoid generating them multiple times simply to achieve the landscape orientation.

Robert Penridge
  • 8,424
  • 2
  • 34
  • 55
Loop
  • 11
  • 2

2 Answers2

3

Order of operations.

Your options statement is after your ODS PDF statement. So at the first run it's created with the default value or whatever was set. Then the option is changed but the file has already been opened/created. At the second run the option has changed so you obtain your desired orientation.

Reeza
  • 20,510
  • 4
  • 21
  • 38
  • I don't think placing the options statement after ODS PDF should be a problem. Code works fine for me on 9.3M1 Win. You can switch orientation back and forth within the same ods pdf block. (Vaguely remember this might have been buggy in older version??) Wonder what version @Jarlh is on? – Quentin May 12 '15 at 21:07
  • I am on 9.4M0. Changing the order of the statement seem to work for me now. However, if i remember correctly i tried this already and it didnt work in early attemds. strange thing – Loop May 13 '15 at 06:35
1

You have to close all open ODS listings before doing this.

ods all close;

at the beginning of you code should do the trick.

Stephan
  • 11
  • 1