BookmarkSubscribeRSS Feed
maheshminnakanti
Calcite | Level 5

Hi I am trying to generate a hbar plot using sgpanel where I need to shade the region of the plot based on the response var values (MPG_Highway in below example). But till now I couldn't find any way to that so can any one suggest a solution for this.

Here is the example:

PROC SGPANEL DATA=sashelp.cars;

where type in("SUV","Sedan","Wagon");

PANELBY type / COLUMNS=3 NOVARNAME ;

HBAR EngineSize / RESPONSE=MPG_Highway GROUP=Cylinders;

COLAXIS values=(1 to 30 by 1) ;

ROWAXIS values=(1 to 30 by 1);

TITLE1 "cars";

run;

quit;

 

I want to shade with color light gray if the MPG_highway is greater than 13 if not gt 13 than shade in light yellow.

 

Thank you,

3 REPLIES 3
Jay54
Meteorite | Level 14

There is no direct way to do this.  However, you can add another plot that will cover the entire data area and color that by the group value.  With SAS 9.4, you can use the POLYGON plot.  Or, you could use a SCATTER, with GROUP and make the marker size big so it covers the data area.  Make sure to set the OFFSETMIN and MAX on both axes to zero.

 

For a general idea, see:  http://blogs.sas.com/content/graphicallyspeaking/2014/02/22/datalattice-with-gradient-backgrounds/.  Here I have used GTL and a BUBBLEPLOT.  I think you could do this with SGPANEL too.

DanH_sas
SAS Super FREQ

When you say "shade the region of the plot", are you talking about the bar chart, or the plot background?

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 1180 views
  • 0 likes
  • 3 in conversation