Data visualization with SAS programming

Adding Background Color to Graph

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 14
Accepted Solution

Adding Background Color to Graph

Hi,

 

I'm creating a graph using Proc SGPLOT. I'm adding this graph to a RTF document. I have attached my code as well as a screen snapshot of the graph.

 

  1. I would like to add background color to the graph. I tried using Proc Template to add background color but it doesn't seem to work. Can you please guide me as to what I may be doing wrong?
  2. How do I remove the outer boundary of the graph? I suspect that once I get the Proc Template to work, it'll be possible.

Thank you very much for your guidance!

SM

Attachment
Attachment

Accepted Solutions
Solution
‎08-03-2016 11:00 PM
SAS Super FREQ
Posts: 862

Re: Adding Background Color to Graph

Great! Then, this will be straightforward:

 

1. To get rid of the outer border, use the NOBORDER option on the ODS GRAPHICS statement:

     ods graphics / noborder;

 

2. Use the BACKCOLOR option on the STYLEATTRS statement in PROC SGPLOT to set a background color:

    proc sgplot data=whatever;

    styleattrs backcolor=cxffffff;

    hbar ... ;

    run;

 

Other related options that might interest you are the WALLCOLOR option on the STYLEATTRS statement, as well as the NOWALL and NOBORDER options on the PROC SGPLOT statement. These "NO" options control the visibility of the wall fill area (NOWALL) and the wall border (NOBORDER).

 

Hope this helps!

Dan

View solution in original post


All Replies
Frequent Contributor
Posts: 142

Re: Adding Background Color to Graph

Hi,

 

Now you are using SGPLOT, try to use the option TMPLOUT= to export the SGPLOT template and then try to add this option BACKGROUNDCOLOR= style-reference | color.

 

Occasional Contributor
Posts: 14

Re: Adding Background Color to Graph

 
 

 
Frequent Contributor
Posts: 142

Re: Adding Background Color to Graph

Hi smajid,

 

Yes, with TMPLOUT a .sas file is generated. This sas file contain the proc template necessary to generate the shell to produce your output. You could modify this code, including the background. Each proc template give a name to the shell.

 

proc template; 
  define statgraph _TMPLNAME_; 

 

After that, you could use a proc sgrender to use your original dataset and your modified template to produce the desired output.

proc sgrender data=_IN_ template=_TMPLNAME_;
run;

 

I hope that it is now clearer

Occasional Contributor
Posts: 14

Re: Adding Background Color to Graph

 
 
 
 
SAS Super FREQ
Posts: 862

Re: Adding Background Color to Graph

What version of SAS are you using? There have been options added to SGPLOT that can do both of your items in a straightforward way.

Occasional Contributor
Posts: 14

Re: Adding Background Color to Graph

DanH_sas,

 

Thank you for your response!

 

I'm using SAS Studio v3.5. The sas engine is: SAS release: 9.04.01M3P06242015

It is the SAS OnDemand for Academics.

Solution
‎08-03-2016 11:00 PM
SAS Super FREQ
Posts: 862

Re: Adding Background Color to Graph

Great! Then, this will be straightforward:

 

1. To get rid of the outer border, use the NOBORDER option on the ODS GRAPHICS statement:

     ods graphics / noborder;

 

2. Use the BACKCOLOR option on the STYLEATTRS statement in PROC SGPLOT to set a background color:

    proc sgplot data=whatever;

    styleattrs backcolor=cxffffff;

    hbar ... ;

    run;

 

Other related options that might interest you are the WALLCOLOR option on the STYLEATTRS statement, as well as the NOWALL and NOBORDER options on the PROC SGPLOT statement. These "NO" options control the visibility of the wall fill area (NOWALL) and the wall border (NOBORDER).

 

Hope this helps!

Dan

Occasional Contributor
Posts: 14

Re: Adding Background Color to Graph

DanH_sas,

 

Thank you very much! I tried your two recommendations and they worked. Appreciate your help a lot!

 

SM

Post a Question
Discussion Stats
  • 8 replies
  • 590 views
  • 2 likes
  • 3 in conversation