BookmarkSubscribeRSS Feed
DrAbhijeetSafai
Lapis Lazuli | Level 10

I have googled a  lot for more than 2 hours but I could not find a solution. 

 

Problem: I want to use patterns in graphs, which I am able to do perfectly by using fillpattern keyword in vbar statement of proc sgplot. To this level all fine. 

 

Now I want to continue using the patterns but do not want colors. I want to make it black and white. I am not able to understand how to do it. 

 

Thanks in advance.

 

- Dr. Abhijeet Safai

Dr. Abhijeet Safai
Certified Base and Clinical SAS Programmer
Associate Data Analyst
Actu-Real
3 REPLIES 3
Rick_SAS
SAS Super FREQ

Please post the PROC SGPLOT statements that you are currently using.

MarciaS
SAS Employee

Hi,

 

If you want to have empty bars with black lines for the patterns, you can add the NOFILL and FILLPATTERNATTRS=(COLOR=BLACK) options on your VBAR statement in PROC SGPLOT. 

If you are creating grouped bars using the GROUP= option on the VBAR statement, you will also need to include the OUTLINEATTRS=(COLOR=BLACK) option to outline the bars in black. 

Below is sample code to demonstrate this. 

I hope this helps.

Regards,

Marcia 

 

proc sgplot data=sashelp.class;
  vbar name /  fillpattern nofill 
               fillpatternattrs=(color=black);
run;
/* Grouped bars */
ods graphics /attrpriority=none; 
proc sgplot data=sashelp.class;
  vbar name /  fillpattern nofill 
               fillpatternattrs=(color=black)
               group=sex outlineattrs=(color=black); 
run;
Rick_SAS
SAS Super FREQ

For groups, you might want to use the GROUPDISPLAY=CLUSTER option (unless you want a stacked bar chart): 

ods graphics /attrpriority=none; 
proc sgplot data=sashelp.cars(where=(type^='Hybrid'));
  vbar type /  fillpattern nofill 
               fillpatternattrs=(color=black) groupdisplay=cluster
               group=origin outlineattrs=(color=black); 
run;

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
  • 3 replies
  • 965 views
  • 3 likes
  • 3 in conversation