BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
smajid
Obsidian | Level 7

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


HorizontalBarGraph_with_nobackground.jpg
1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

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

8 REPLIES 8
arodriguez
Lapis Lazuli | Level 10

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.

 

smajid
Obsidian | Level 7
 
 

 
arodriguez
Lapis Lazuli | Level 10

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

smajid
Obsidian | Level 7
 
 
 
 
DanH_sas
SAS Super FREQ

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.

smajid
Obsidian | Level 7

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.

DanH_sas
SAS Super FREQ

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

smajid
Obsidian | Level 7

DanH_sas,

 

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

 

SM

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 8 replies
  • 8340 views
  • 2 likes
  • 3 in conversation