BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
endofline
Obsidian | Level 7

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! 

1 ACCEPTED SOLUTION
6 REPLIES 6
endofline
Obsidian | Level 7

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! 

DanH_sas
SAS Super FREQ

Add markercolor to your dataset to change the marker colors.

endofline
Obsidian | Level 7

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? 

Jay54
Meteorite | Level 14

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 6 replies
  • 27595 views
  • 7 likes
  • 4 in conversation