BookmarkSubscribeRSS Feed
Leef88
Calcite | Level 5

I see this following bar chart that made by SAS viya I guss. Wonder if this can be done in PC SAS? Thanks!

 

https://communities.sas.com/t5/SAS-Visual-Analytics/Color-Code-in-Bar-Charts/m-p/855434/emcs_t/S2h8Z...

3 REPLIES 3
PaigeMiller
Diamond | Level 26

You can probably do something very close to this using ODS LAYOUT GRIDDED

 

But, do I have an example? No I don't.

--
Paige Miller
DanH_sas
SAS Super FREQ

@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.

 

cars.png

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;
PaigeMiller
Diamond | Level 26

I always learn something when you write, @DanH_sas ! 💙

--
Paige Miller

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 3 replies
  • 804 views
  • 4 likes
  • 3 in conversation