Graphics Programming

Data visualization using SAS programming, including ODS Graphics and SAS/GRAPH. Charts, plots, maps, and more!
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
brgray
Calcite | Level 5

i'd like to place output from 2 or more sgscatter plots on the same row. so, imagine that i have two sgscatter statements. i'd like them to both show up on the same row (rather than sequentially). see below for an example. thanks for suggestionsCapture.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

As Reeza says, the ODS LAYOUT GRIDDED statement is a great choice for destinations that support it. For details and examples, see

 

"Using the ODS statement to add layers in your ODS sandwich"

and

"Arrange matrices and graphs in a gridded layout"

 

Your code might look like this:

 

ods graphics / width=500px height=500px;
ods layout gridded columns=2 advance=table;

proc sgscatter data=FIRST;
...
run;

proc sgscatter data=SECOND;
...
run;

ods layout end;

 

 

View solution in original post

9 REPLIES 9
Reeza
Super User

What's your destination?

ODS HTML, PDF, RTF?

 

If PDF it supports a COLUMN statement so if you specify two columns they'll come side by side.

 

You can also look at ODS LAYOUT and/or SGPANEL as alternate options but they're more complex.

brgray
Calcite | Level 5

thanks. html but i could make it pdf. i may not have been sufficiently clear about my objective. sgpanel doesn't support what i'm looking to do--altho it would come close to doing so if i could place multiple sgpanel outputs side by side. from your ods layout suggestion, i see where i might be able to generate side-by-side matrix plots using ods document (altho i'm hoping for a simpler solution).

Reeza
Super User
options orientation=landscape;

ods pdf file='C:\_localdata\temp\demo.pdf' columns=2 style=seaside;

ods graphics / width= 4in height=5in;

proc sgscatter data=sashelp.class;
matrix age weight height / group=sex;
run;

proc sgscatter data=sashelp.cars;
matrix mpg_city mpg_highway msrp invoice;
run;

ods pdf close;

COLUMNS is the easiest option - make sure you set the graphs to a size that will fit on the page. Fully worked example above.

brgray
Calcite | Level 5

Hi Reeza, many thanks for your and Rick's solutions.

Rick_SAS
SAS Super FREQ

As Reeza says, the ODS LAYOUT GRIDDED statement is a great choice for destinations that support it. For details and examples, see

 

"Using the ODS statement to add layers in your ODS sandwich"

and

"Arrange matrices and graphs in a gridded layout"

 

Your code might look like this:

 

ods graphics / width=500px height=500px;
ods layout gridded columns=2 advance=table;

proc sgscatter data=FIRST;
...
run;

proc sgscatter data=SECOND;
...
run;

ods layout end;

 

 

brgray
Calcite | Level 5

hi. this works great (even with a BY statement)--with one hitch. the hitch is that repeat uses of the code lead to pages that are centered on the right margin of my screen (ie much of the plot is off screen). a not-so-great fix is to close the html output; perhaps someone can provide a less drastic fix? many thanks.

 

my current code is as follows:

title1 "Matrix plots";
ods graphics / width=400px height=400px;
ods layout gridded columns=3 advance=table;
proc sgscatter data=zibout32(where=(sim le 3));
matrix b00psi_ g00p_ taupsi_ b0psi_1 b0psi_10;
by b0 b1 b1SD b2 g0 g1 g1SD g2 taupsi rho taup taupsite seasons sites n_ sim;
run;

Rick_SAS
SAS Super FREQ

You need to end the layout;

ODS LAYOUT END;

brgray
Calcite | Level 5
yup. thanks.
brgray
Calcite | Level 5

ignore my comment re centering; this problem appears to have been caused by my failure to add ods layout end;

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 7475 views
  • 2 likes
  • 3 in conversation