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
Please post the PROC SGPLOT statements that you are currently using.
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;
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;
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!
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.