Hi,
I am using SAS 9.1.3, and here is the test code:
test code |
---|
goptions reset=all ; options orientation=portrait; ods listing close; ods pdf startpage=never; ods pdf file="C:\aa.pdf" ; ** A Listing; proc print data=sashelp.class; run; ** A graph; symbol v=dot h=2 c=blue; proc gplot data=sashelp.class; plot height*weight; run; quit; ods pdf close; ods listing; |
And here is the result:
It seems that when creating the graph, SAS takes the whole page as the canvas and it didn't 'see' that a listing was already on the page.
Question is: is there a way to make SAS automatically display the graph right after the listing?
For example, suppose we need to create a 4inch*3inch scatterplot,
if there's a listing(PROC PRINT) before the GPLOT, then display the graph after the listing;
if there's no listing, then directly display the graph at the top of the page.
Any help will be highly appreciated, thanks!!!
With SAS9.4 the following code sample will do what you are after. It uses the ODS LAYOUT feature. Before each output you create you will have an ODS REGION statement, to say you are starting a new region to place output into. I might not do the exact same thing in SAS9.1.3, but have a go.
hi
You can use the following options to control the start position and size of the graph.
goptions
horigin=4cm
vorigin=4cm
hsize=14cm
vsize=12cm
;
Please note, that the lower left corner is the zero point for the HORIGIN and VORIGIN
Thanks!
However, after the settings of HORIGIN / VORIGIN/ HSIZE / VSIZE, the graph will be on a fixed position of the page, no matter how long the listing is.
Hi,
Your point being? If there is a lot of data in the listing, then its going to take up more space on the page. You could check the number of rows in the dataset being listed, then adjust your options accorindingly, e.g.:
proc sql;
select 20 - (select NOBS from SASHELP.VTABLE where LIBNAME="WORK" and MEMNAME="THETABLE")
into :NUM_CM
from SASHELP.CLASS;
quit;
goptions horigin=&NUM_CM.cm vorigin=4cm hsize=14cm vsize=&NUM_CM.cm;
Just an untested example above. But this only means that if the data exapnds you graph will shrink. Paper size is fixed. You could try listing the data with smaller font, dropping the ZOOM aspect of the graph etc. but if your data is changing/growing you will always hit this fixed paper size.
Thank you!
It's a good idea.
This paper may also be of interest. I talks about using ODS LAYOUT to position output at specific areas on the PDF
With SAS9.4 the following code sample will do what you are after. It uses the ODS LAYOUT feature. Before each output you create you will have an ODS REGION statement, to say you are starting a new region to place output into. I might not do the exact same thing in SAS9.1.3, but have a go.
ODS LAYOUT works.
Thank you very much!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.