BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
UcheOkoro
Lapis Lazuli | Level 10

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;

UcheOkoro_0-1662562736651.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

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';

 

View solution in original post

2 REPLIES 2
Rick_SAS
SAS Super FREQ

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';

 

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
  • 2 replies
  • 435 views
  • 1 like
  • 2 in conversation