Data visualization with SAS programming

Background color in SGPLOT

Reply
Frequent Contributor
Posts: 115

Background color in SGPLOT

Hi all,
I am using sgpot in a stored proc to output a report on the IDP.
I can seem to figure out how to control the chart background color of my sgplot output. I an using the below template.

proc template;
define style mystyle;
parent=styles.STATISTICAL;
class body/
backgroundcolor=white
color=black
fontfamily="Verdana, Arial" ;
class systemtitle/
fontfamily="Verdana, Arial"
fontweight=bold
fontsize=14;
class table/
backgroundcolor=white
bordercolor=black
borderstyle=solid
borderwidth=1pt ;
class header, footer/
backgroundcolor=green
fontfamily="Verdana, Arial"
fontweight=bold ;
class data/
fontfamily="Verdana, Arial";
style graphcolors from graphcolors /
'gcdata1'=Darkseagreen
'gcdata2'=Khaki
'gcdata3'=Darkslateblue
'gdata1'=Darkseagreen
'gdata3'=Darkslateblue
'gdata4'=CXDC531F
'gdata2'=Khaki;
style GraphBackground
"Graph backgroundcolor attributes" /
backgroundcolor = colors("white")
textalign = L
verticalalign = B;

end;
run;

I then pass this to the %STPBEGIN macro. %let _ODSSTYLE=mystyle;


This section in my proc creates the plot:
ods graphics / reset width=500px height=333px noborder;
proc sgplot data=repo.No_Activity_018 ;
vbar Inactive_Days_Bin /group=Plan ;
run;
quit;

I can't find any reference to overridding the background color directly in SGPLOT in the SAS documentation.
SAS Super FREQ
Posts: 864

Re: Background color in SGPLOT

I think if you remove the colors("white") and replace it with just "white" (no quotes), does it work for you?
Frequent Contributor
Posts: 115

Re: Background color in SGPLOT

No.

style GraphBackground
"Graph backgroundcolor attributes" /
backgroundcolor = white
textalign = L
verticalalign = B;

It compiles, but the color is still gray.
SAS Super FREQ
Posts: 8,646

Re: Background color in SGPLOT

Hi:
Can you look in the log for errors or notes. I'm guessing that your updated style template is not found on the server where output for the IDP is being created. You should see a note in the log to the effect:
[pre]
WARNING: Style xxxxxxxx not found; Default style will be used instead.
[/pre]

You might want to work with Tech Support on this issue. Depending on when/how/where your template is being compiled and saved, you may need an ODS PATH statement so that the Stored Process can find the updated template.

Have you tested your style template code in Base SAS (outside a Stored Process to make sure that the code has the desired result)??

cynthia
Frequent Contributor
Posts: 115

Re: Background color in SGPLOT

OK.
Well on that note, how do I view the log on a stored procedure running on Stored Procedure server?
SAS Super FREQ
Posts: 864

Re: Background color in SGPLOT

Try setting the color to the COLOR attribute instead of the BACKGROUNDCOLOR attribute. For ODS GRAPHICS, I believe is where the color os retrieved.

Thanks!
Dan
Frequent Contributor
Posts: 115

Re: Background color in SGPLOT

Disregard.
DanH ur initial suggestion of " backgroundcolor = white " worked.
I did not see the results as I am using the tagsets.tableeditor template and this that script happpends to create a style tmeplate also called MyStyle. This was replacing my style template.

Thanks.
Post a Question
Discussion Stats
  • 6 replies
  • 652 views
  • 0 likes
  • 3 in conversation