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: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 3 replies
  • 711 views
  • 4 likes
  • 3 in conversation