Reputation: 577
I am trying to get some datasets printed to a PDF. Can anyone tell me how I can fit the last 4 proc print
statements into a 2 x 2 on a single page, while leaving the first one on it's own page (as it is now)?
title;
options nodate nonumber nocenter orientation=portrait spool;
ods pdf file="I:\ASR\201410\bio.pdf" color=yes style=fancyprinter;
ods pdf startpage=NEVER;
ods escapechar='';
ods pdf text='S={just=CENTER preimage="I:/asr/logo.png" posttext=""';
ods pdf text= "S={just=c font_weight=bold font_size=12pt font_face=Arial}Fall 2013 - Annual Statistical Report";
ods pdf text= "S={just=c font_weight=bold font_size=12pt font_face=Arial}Department of Biology";
proc print data=IntApps_AY_cnt_p noobs; TITLE "Applications"; run;
ods pdf startpage=now;
proc print data=enroll_cnts_np noobs; TITLE "New Student Enrollment"; run;
ods pdf startpage=now;
proc print data=enroll_cnts_p noobs; TITLE "Total Enrollment"; run;
ods pdf startpage=now;
proc print data=TuitionScholarships_cnt_p noobs; TITLE "Stipends"; run;
ods pdf startpage=now;
proc print data=asr_degs_cnts_p noobs; TITLE "Academic Year 2012-2013 Awarded Degrees"; run;
ods layout end;
ods all close;
Thanks
JT
Upvotes: 2
Views: 1230
Reputation: 63424
I think you might need to use ODS LAYOUT
to accomplish this. If you have SAS 9.4, you might consider also learning PROC ODSTABLE
or one of the other PROC DOCUMENT
related procs (see this doc page for more details). The ODS LAYOUT
solution will work in SAS 9.3+, and might work in SAS 9.2, but I think it was very rusty back then.
The basic code would be something like
ods pdf file="c:\temp\blah.pdf";
proc print data=sashelp.class;
run;
ods pdf startpage=now;
ods layout start columns=2;
ods region;
proc print data=sashelp.class;
run;
ods region;
proc print data=sashelp.class;
run;
ods region;
proc print data=sashelp.class;
run;
ods region;
proc print data=sashelp.class;
run;
ods layout end;
ods pdf close;
You get 2 columns this way. You would still have to control the rows by making things not too big; if that is an issue, you can control the height/width of the individual regions on the ods region
statements (ods region height=4in
), but that may or may not cause an issue in your results, since only some SAS outputs will scale the output to fit the space.
More information can be found in You Did That Report in SAS®!?: The Power of the ODS PDF Destination.
Upvotes: 1
Reputation: 1078
Use the columns=N
option in ODS
to divide a page up into N columns. Try to manipulate the number of columns to fit your data sets. Then use startpage=no
and startpage=now
to help you output your print
statements in desired places.
SAS views each column as a new page, so you can exploit this to fit multiple print
statement outputs onto one page.
Example using 2 columns:
options nodate nonumber;
data work.animals;
input name $ weight;
datalines;
monkey 20
shark 500
lion 200
wolf 120
buffalo 400
Parrot 10
Lizard 30
Human 150
Whale 1000
;
run;
ods pdf file = 'C:\sasdata\animals2.pdf' columns = 2;
ods pdf startpage=no;
proc print data=work.animals; /* This print will be on a seperate page */
title 'Seperate Paged Animals';
run;
ods pdf startpage=now;
ods pdf text="I want a little paragraph here that explains things about
columns and startpages for putting this proc print statement on a
seperate page. The other four statements will be outputed
onto one page only divided into two columns.";
ods pdf startpage=now;
title;
proc print data=work.animals; /* 2nd print*/
run;
proc print data=work.animals; /*3rd print*/
run;
ods pdf startpage=now;
proc print data=work.animals; /*4th print*/
run;
proc print data=work.animals; /*5th print*/
run;
ods pdf close;
ods listing;
When we type startpage=now
, it'll only go to a new column instead of a new page. Hence, the first print
statement and the paragraph of text will be on a separate page. The last four print
statements will be on one page.
Upvotes: 1