I see this following bar chart that made by SAS viya I guss. Wonder if this can be done in PC SAS? Thanks!
You can probably do something very close to this using ODS LAYOUT GRIDDED
But, do I have an example? No I don't.
@PaigeMiller is correct. To create multiple bar charts with different response variables in one graph, you would need to use either the Graph Template Language (GTL), or use ODS LAYOUT with the SG procedures (SGPLOT in this case). If you were using the same response variable with multiple classifiers, your best option is to use the SGPANEL procedure.
ODS LAYOUT is normally applied at the page level. However, there is a trick for generating the output via ODS PRINTER such all of the output is generated in one image. I talk about this technique more in-depth in this blog post . The example below demonstrates this technique using bar charts.
ods _all_ close;
options nodate nonumber;
options leftmargin="0.001in" rightmargin="0.001in";
options papersize=(7.35in 2.00in);
title "Car Statistics";
ods printer printer=png300 file="cars.png" style=htmlblue;
ods layout gridded columns=3 advance=proc
column_gutter=0.1in row_gutter=0.1in;
ods graphics / width=2.25in noborder;
title;
proc sgplot data=sashelp.cars noopaque;
yaxis grid;
vbar origin / response=horsepower fillattrs=GraphData1 transparency=0.5;
run;
proc sgplot data=sashelp.cars noopaque;
yaxis grid;
vbar origin / response=mpg_city fillattrs=GraphData2 transparency=0.5;
run;
proc sgplot data=sashelp.cars noopaque;
yaxis grid;
vbar origin / response=mpg_highway fillattrs=GraphData3 transparency=0.5;
run;
ods layout end;
ods printer close;
I always learn something when you write, @DanH_sas ! 💙
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.