Hi All, I'm running SAS 9.4 and trying to plot a scatter plot with 5 groups, using proc sgplot. I would like my groups on the scatter plot to have different markers than the standard open circle and different colors. I did some hunting online and thought I found a possible solution, however it has not worked.
%modstyle ( parent=analysis,
name=mystyle,
type=CLM,
colors=green blue yellow orange red,
markers=circle plus diamond asterisk circlefilled);
ods listing style=mystyle;
proc sgplot data=hospitals;
scatter x=avg_payment y=score/group=rank;
run;
Does anyone have any insight in how to change the scatter plot markers & colors? Thanks!
Attribute Maps
A full example is here
http://blogs.sas.com/content/graphicallyspeaking/2012/02/27/roses-are-red-violets-are-blue/
Theres probably newer ever stuff on here if you search with the term attribute map.
Attribute Maps
A full example is here
http://blogs.sas.com/content/graphicallyspeaking/2012/02/27/roses-are-red-violets-are-blue/
Theres probably newer ever stuff on here if you search with the term attribute map.
Thanks for your response. i tried your suggestion, sadly it didn't work for me. Here is my code:
data myattrmap;
length linecolor $ 9 fillcolor $ 9;
input ID $ value $ linecolor $ fillcolor $;
datalines;
myid 1 blue blue
myid 2 yellow yellow
myid 3 green green
myid 4 orange orange
myid 5 red red
;
run;
proc sgplot data=hospitals dattrmap=myattrmap;
scatter x=avg_payment y=score/group=rank attrid=myid;;
run;
Is there something that I'm missing. Also, is there a way to also change the marker using this method? Might this be an issue since I'm using enterprise?
Thanks!
Add markercolor to your dataset to change the marker colors.
Thanks that worked for the colors, what would I need to add to change the marker style from an open circle, say to a asterisk?
Actually answered my own question. Need to add markersymbol.
Reeza's solution will work, especially if you want specific colors and symbols for specific group values. If you want custom colors and symbols, but don't care which group value gets which one, you can use the STYLEATTRS statement in SGPLOT. Use the DataColors, DataContrastColors, DataSymbols and DataLinePatterns to provide your own list of attributes each. Also, be sure to use ATTRPRIORITY=None to ensure you get color and symbol cycling.
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.