BookmarkSubscribeRSS Feed
Calcite | Level 5

I meet a issue in work. client ask a plot like below.

the first way I do is using PROC SGPANEL. But the issue is , I can't show the x-axis and y-axis in each small cell. additional, there is a blank cell at the bottom right. I don't know how to remove it.

the second way, using PROC GPLOT to draw each subject, than use GREPLAY to put them together. but the issue is ,how to draw the legend?

Is anyone have a good solution for this?

thanks a lot!


Diamond | Level 26 RW9
Diamond | Level 26


Try out proc template and GTL as you will have more control.

Also, have a look at this blog which details quite a lot with regards to graphs:

Quartz | Level 8


Robert Allison has some great information on the Web (google); in SAS sites; and in his book "SAS/GRAPH Beyond the basics".  I have seen or encountered each of your problems. The documentation by Robert Allison and others helped me solve the problems.  Unfortunately, there was no quick fix for my problems.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Meteorite | Level 14

Assuming you've got the gplots & greplay looking the way you want, and the only remaining question is the shared legend, here is an example that should be exactly what you need...

(p.s. - Thanks jwillis!)

Calcite | Level 5

I have visited your website before. There are a lot of example which are useful to us. thanks very much!

You link is a good way to resolve by gplot and greplay.

But I am more interested in GTL. Because I have got original plot by GPANEL. the plot is much more complex than the sample I show. it will be a lot work to change it to use gplot.

About GTL, which layout should I chose? I have look into the GTL early. for multi-cell layouts, LATTICE can be use. but in documents, 'All cells must be predefined'. does this mean I have to define 5 times if there are 5 cells in one graph? And in early test, if I define 2 cells, and if there is no data for second cell, the blank frame will still show.

about DATAPANEL and DATALATTICE, it is sample. But I think this is same as SGPANEL, right?


You best choice for this type of plot is PROC SGSCATTER.

proc sort out=cars; by msrp; run;

proc sgscatter data=cars (obs=50);

plot (weight horsepower mpg_city mpg_highway)*msrp / group=type join;




After looking at your example further, it looks like you need reference lines, which are not currently supported in SGSCATTER. Therefore, you would need to use either GTL or the GPLOT/GREPLAY combo.

Calcite | Level 5

Yes. actually, each small plot is more complex than the sample. I think it can't support by SGSCATTER.

And I am more interested in GTL.

Calcite | Level 5

Here is another graph I need to draw. it is more complex. I created it by SGPANEL. but at last page, there is a blank cell which need be removed. and client ask to add x-axis if it is possible.  So I try to resolve it by GTL.




Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg



Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 8 replies
  • 5 in conversation