BookmarkSubscribeRSS Feed
DrAbhijeetSafai
Pyrite | Level 9

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
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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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