BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
pobel
Calcite | Level 5

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:

Capture.JPG

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!!!

1 ACCEPTED SOLUTION

Accepted Solutions
BrunoMueller
SAS Super FREQ

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.

goptions reset=all   ;

options orientation=portrait;

ods _all_ close;

ods pdf startpage=never;

ods pdf file="C:\temp\aa.pdf" ;

ods layout gridded columns=1;
ods region;

** A Listing;
proc print data=sashelp.cars(obs=40);
  var make model type driveTrain invoice horsepower;
run;


ods region;
** A graph;

goptions
/*  horigin=8cm*/
/*  vorigin=8cm*/
 
hsize=8cm
 
vsize=8cm
;

symbol v=dot h=2 c=blue;
proc gplot data=sashelp.class;
   plot height*weight;
run;
quit;
ods layout end;

ods pdf close;

ods listing;

View solution in original post

7 REPLIES 7
BrunoMueller
SAS Super FREQ

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

pobel
Calcite | Level 5

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.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

pobel
Calcite | Level 5

Thank you!

It's a good idea.

BrunoMueller
SAS Super FREQ

This paper may also be of interest. I talks about using ODS LAYOUT to position output at specific areas on the PDF

http://analytics.ncsu.edu/sesug/2008/SIB-097.pdf

BrunoMueller
SAS Super FREQ

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.

goptions reset=all   ;

options orientation=portrait;

ods _all_ close;

ods pdf startpage=never;

ods pdf file="C:\temp\aa.pdf" ;

ods layout gridded columns=1;
ods region;

** A Listing;
proc print data=sashelp.cars(obs=40);
  var make model type driveTrain invoice horsepower;
run;


ods region;
** A graph;

goptions
/*  horigin=8cm*/
/*  vorigin=8cm*/
 
hsize=8cm
 
vsize=8cm
;

symbol v=dot h=2 c=blue;
proc gplot data=sashelp.class;
   plot height*weight;
run;
quit;
ods layout end;

ods pdf close;

ods listing;
pobel
Calcite | Level 5

ODS LAYOUT works.

Thank you very much!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 1248 views
  • 3 likes
  • 3 in conversation