Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SAS: How do I use ODS layout to put 8 graphs on 2 PDF pages?

I am using SAS ODS to create PDF documents. The code below works to put 4 graphs on 1 page. But if I try to put 8 graphs on 2 pages, all I get is 4 graphs on 1 page. I tried copying the part between the lines of asterixes and pasting it again above "ods pdf close;" but that didn't work. I also tried adding "ods startpage = now;" between the two, but that didn't work either. How can I put 8 graphs on 2 pages?

goptions reset=all;

data test;
input x y @@;
datalines;
1 2 2 4 3 8 4 10 5 15
;
run;
ods pdf file="[path]/output.pdf" ;

****
ods layout Start width=10in height=8in ;
ods region x=0 y=5% width=45% height=45%;
proc gplot data=test;
title2 'PLOT #1';
plot y*x /name="mygraph1" noframe;
run;
ods region x=55% y=5% width=45% height=45%;
title2 'PLOT #2';
plot y*x /name="mygraph2" noframe;
run;
ods region x=0 y=51% width=45% height=45%;
title2 'PLOT #3';
plot y*x / name="Mygraph3" noframe;
run;
ods region x=55% Y=51% width=45% height=45%;
title2 'PLOT #4';
plot y*x / name="Mygraph4" noframe;
run;
quit;
ods layout end;
****

ods pdf close;

The code is based on this article.

like image 704
BB1 Avatar asked Feb 18 '11 19:02

BB1


1 Answers

Good question, in my opinion this is something that is VERY poorly documented anywhere.

You're nearly there: you need to close your layout "container", force a new page, then open a new layout for the next page:

ods pdf file="file.pdf" startpage=never;

* page 1;
ods layout start <dimensions>;
ods region <dimensions>;
proc whatever; run;
ods region <dimensions>;
proc whatever; run;
ods layout end;

*<etc. for page 1 content>;

* start page 2;
ods pdf startpage=now;

* page 2;
ods layout start <dimensions>;
ods region <dimensions>;
proc whatever; run;
ods region <dimensions>;
proc whatever; run;
ods layout end;

*<etc. for page 2 content>;

ods pdf close;
like image 149
sasfrog Avatar answered Oct 13 '22 12:10

sasfrog