Please, I need help with changing the colors of the plots to shades of gray and black. I would also like to have different symbols for the legend. In addition, I need help changing the overall font size of the main label.
Thank you.
The following are my SAS code and plot
proc sgplot data=CHERRYP.violation_score4 ;
scatter y=late_Violation2 x=Provider /group=Designation yerrorlower=Lower_CL_late yerrorupper=Upper_CL_late markerattrs=(symbol=diamondfilled);
refline 0 / axis=y ;
xaxis grid;
yaxis grid discreteorder=data reverse label="Late Violation" LABELATTRS=(family="Arial" size=12)
valueattrs=(family=Arial size=10);
keylegend / location=outside
titleattrs=(size=12)
valueattrs=(family=Arial size=12);
xaxis display=( noticks novalues) label="Provider" LABELATTRS=(family="Arial" size=12)
valueattrs=(family=Arial size=10);
title 'Cherry-Picking Late Violation by Provider Designation' ;
run;
You want to use the ATTRPRIORITY=NONE option on the ODS GRAPHICS statement to make sure that the symbols vary with the groups. Then you can use the STYLEATTRS statement in PROC SGPLOT to set the gray colors and symbols for the groups. For example:
/*
https://blogs.sas.com/content/iml/2018/06/13/attrpriority-cycleattrs-styleattrs-ods-graphics.html
*/
data have;
set sashelp.cars;
if MPG_City < 20 then Group="Gas Guzzler ";
else if MPG_City <=30 then Group="Moderate ";
else Group="Fuel Efficient";
run;
ods graphics / AttrPriority=None;
proc sgplot data=have;
styleattrs datacontrastcolors=(LightGray DarkGray Black)
datasymbols=(CircleFilled TriangleFilled Plus);
scatter x=MPG_City y=Weight / group=Group;
run;
For more about ATTRPRIORITY and STYLEATTRS, see "Attrs, attrs, everywhere: The interaction between ATTRPRIORITY, CYCLEATTRS, and STYLEATTRS in ODS g...
Lastly, you can use the TITLE statement to change the font size or family:
title h=10pt f="Arial" 'Cherry-Picking Late Violation by Provider Designation';
You want to use the ATTRPRIORITY=NONE option on the ODS GRAPHICS statement to make sure that the symbols vary with the groups. Then you can use the STYLEATTRS statement in PROC SGPLOT to set the gray colors and symbols for the groups. For example:
/*
https://blogs.sas.com/content/iml/2018/06/13/attrpriority-cycleattrs-styleattrs-ods-graphics.html
*/
data have;
set sashelp.cars;
if MPG_City < 20 then Group="Gas Guzzler ";
else if MPG_City <=30 then Group="Moderate ";
else Group="Fuel Efficient";
run;
ods graphics / AttrPriority=None;
proc sgplot data=have;
styleattrs datacontrastcolors=(LightGray DarkGray Black)
datasymbols=(CircleFilled TriangleFilled Plus);
scatter x=MPG_City y=Weight / group=Group;
run;
For more about ATTRPRIORITY and STYLEATTRS, see "Attrs, attrs, everywhere: The interaction between ATTRPRIORITY, CYCLEATTRS, and STYLEATTRS in ODS g...
Lastly, you can use the TITLE statement to change the font size or family:
title h=10pt f="Arial" 'Cherry-Picking Late Violation by Provider Designation';
Thank you so much! I am grateful.
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.
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.
Ready to level-up your skills? Choose your own adventure.