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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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