Graphics Programming

Data visualization using SAS programming, including ODS Graphics and SAS/GRAPH. Charts, plots, maps, and more!
BookmarkSubscribeRSS Feed
Siri29
Calcite | Level 5
Hello SAS Forum.

Is there any way ,I could set a background color for the bars while using the proc sgpanel.

Here is the sample code for panels(with bars).I want to set a background for bars.
/***************************************************************************************

title1 "Average MPG (City) by Vehicle Origin and Type";

proc sgpanel data = sashelp.cars ;

panelby origin / layout=columnlattice onepanel novarname

noborder colheaderpos=top;

hbar type / response=mpg_city group=type ;

colaxis display=none ;

rowaxis label="Average MPG (City)" ;

keylegend / title="Type" position=right across=1 ;

run;
************************************************************************************/

Any idea on this??

Please let me know..

Appreciate your help.

Thanks

Siri
7 REPLIES 7
DanH_sas
SAS Super FREQ
You can do it by changing the wall color in the style. You can make a little style that inherits from your favorite style but just changes the wall color. Here is a little example:

[pre]
proc template;
define style styles.mybackground;
parent=styles.listing; /* or your favorite style */
style graphwalls from graphwalls /
color=yellow;
end;
run;

ods listing style=mybackground;
[/pre]

Hope this helps,
Dan
Siri29
Calcite | Level 5
Thanks Dan for your quick response.

But somehow I couldn't get the background .

this is the way I proceeded:

/**************************************************************


proc template;
define style styles.mybackground;
parent=styles.listing; /* or your favorite style */
style graphwalls from graphwalls /
color=yellow;
end;
run;

ods listing file = "mybackground" ;

title1 "Average MPG (City) by Vehicle Origin and Type";
proc sgpanel data = sashelp.cars description= "mybackground";
panelby origin / layout=columnlattice onepanel novarname

noborder colheaderpos=top ;

hbar type / response=mpg_city group=type ;

colaxis display=none ;

rowaxis label="Average MPG (City)" ;

keylegend / title="Type" position=right across=1 ;

run;

/******************************************************************

Its giving me a warning:

WARNING: Unsupported device 'ACTIVEX' for LISTING destination. Using device 'ACTXIMG'.


I get the output but not with the background for bars.


Thanks again for your help.

Siri
DanH_sas
SAS Super FREQ
The ODS LISTING statement should read:

ods listing style=mybackground;

Your example had:

ods listing file="mybackground";

Give that a try and see if that works for you.

Thanks!
Dan
Siri29
Calcite | Level 5
Thanks Dan

I did change it...

Its giving me output without any errors,but not with the background

here is what i have done.
/************************************************************************


proc template;
define style styles.mybackground;
parent=styles.listing; /* or your favorite style */
style graphwalls from graphwalls /
color=yellow;
end;
run;

ods listing style = mybackground ;

title1 "Average MPG (City) by Vehicle Origin and Type";
proc sgpanel data = sashelp.cars description= "mybackground";
panelby origin / layout=columnlattice onepanel novarname

noborder colheaderpos=top ;

hbar type / response=mpg_city group=type ;

colaxis display=none ;

rowaxis label="Average MPG (City)" ;

keylegend / title="Type" position=right across=1 ;

run;

/***********************************************************************

Am I calling the template correctly in the Panel block?

Thanks

Sri
DanH_sas
SAS Super FREQ
Hey Siri,

Your code runs correctly for me. Try restarting your SAS session and see if that helps. Your session may be in a state where the style request is getting ignored. Let me know if that works for you.

Thanks!
Dan
Siri29
Calcite | Level 5
Hey Dan

Its the same problem again...
No background

Siri
Siri29
Calcite | Level 5
Thanks Dan

Appreciate your help.

Siri

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 7 replies
  • 1827 views
  • 0 likes
  • 2 in conversation