BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
fja
Lapis Lazuli | Level 10 fja
Lapis Lazuli | Level 10

Dear Community!

I produce a few histograms using sgplot that result in a list (i.e. one column) of plots. Now I wonder if one could have that output to a two column list or - more generally speaking - to a nxm matrix like panel ...

Actually I expected this to  be a FAQ but i could not spot any entry in this forum dealing with it. Might be that I picked the wrong keywords ... or that I am barking up the wrong tree alltogether. 

Any hint is appreciated.

Cheers

Fja

/* just for illustrating what I am doing. hence, no data provided*/
proc sgplot data=have;
  by GroupCol;
  histogram xCol / FREQ=yCol;
run;

edit:

... I should have mentioned that SGPANEL does not seem to be an option, as the graphs are stuck together sharing axis lables ... I am actually aiming at keeping the plots separate and just changing the fashion/order in which  they are displayed.

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

> ... I should have mentioned that SGPANEL does not seem to be an option, as the graphs are stuck together sharing axis lables ... I am actually aiming at keeping the plots separate and just changing the fashion/order in which  they are displayed.

 

It sounds like you want to use the ODS LAYOUT GRIDDED to display two graphs on each rows:

ods layout gridded columns=2 advance=table;
   proc sgplot data=have;
      by GroupCol;
      histogram xCol;
  run;
ods layout end;

DIscussion and examples of the ODS GRIDDED LAYOUT statement at

Use ODS to arrange graphs in a panel

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

Example of histograms using PROC SGPANEL: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/grstatproc/n1nxbz16c4f9b4n1nnrd3aaor1lw.htm#n...

 

I realize you have presented to us fake code, but you should still make sure it at least makes sense. This line makes no sense:

 

 histogram xCol / FREQ=xCol;
--
Paige Miller
fja
Lapis Lazuli | Level 10 fja
Lapis Lazuli | Level 10

Correct. 🙂🙂 ... but "fake" code is a bit harsh, is it not? 🙂

Rick_SAS
SAS Super FREQ

> ... I should have mentioned that SGPANEL does not seem to be an option, as the graphs are stuck together sharing axis lables ... I am actually aiming at keeping the plots separate and just changing the fashion/order in which  they are displayed.

 

It sounds like you want to use the ODS LAYOUT GRIDDED to display two graphs on each rows:

ods layout gridded columns=2 advance=table;
   proc sgplot data=have;
      by GroupCol;
      histogram xCol;
  run;
ods layout end;

DIscussion and examples of the ODS GRIDDED LAYOUT statement at

Use ODS to arrange graphs in a panel

fja
Lapis Lazuli | Level 10 fja
Lapis Lazuli | Level 10
ods layout gridded columns=2 advance=table;
ods layout end;

Hi Rick!

This did it. Thank you very much! The link to provided is great!

Cheers 

Folkert

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 4 replies
  • 1205 views
  • 4 likes
  • 3 in conversation