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.
> ... 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
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;
Correct. 🙂🙂 ... but "fake" code is a bit harsh, is it not? 🙂
> ... 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
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
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.