Monday, September 25, 2017

Hack 6.2 Printing in Portrait and Landscape Mode in the Same Document



SAS Programming Professionals,

Did you know that you can change the orientation of printed SAS reports between portrait and landscape?

This can be done by specifying either PORTRAIT (the default) or LANDSCAPE as the value of the ORIENTATION option.

Here is an example of creating a report in a PDF file with the ORIENTATION option specified as landscape and then as portrait:

ods _all_ close;
ods noresults;
title2 'Switching PDF orientation on the fly';
ods pdf notoc  file="%sysfunc(pathname(WORK))\ChangeOrientation.pdf";

title3 'Females in Landscape';
options orientation=landscape;

proc print  data=sashelp.class;
where sex = 'F';
run;

title3 'Males in Portrait';
options orientation=portrait;

proc print  data=sashelp.class;
where sex = 'M';
run;

ods pdf close;

The first OPTIONS statement specifies to print in landscape mode, so the first report created in the PDF has that orientation.  The second OPTIONS statement specifies portrait mode, so the second report is printed with the portrait orientation.  Don’t forget that the ORIENTATION option is a system option, and the value you change it to is in effect for the duration of your SAS program… unless, of course, you change it back again.

Best of luck in all your SAS endeavors!


---MMMMIIIIKKKKEEEE
(aka Michael A. Raithel)
Author of the new cult classic for computer programmers:  It Only Hurts When I Hit <ENTER>
Print edition:  http://tinyurl.com/z8bzx2e 
Kindle edition: http://tinyurl.com/zypgqa7 

The hack above is an excerpt from the book:  Did You Know That?  Essential Hacks for Clever SAS Programmers

No comments:

Post a Comment