I have multiple states that I'm trying to plot suppression and stability for using different thresholds on one plot. I've already plotted suppression and stability for different states (represented by different symbols) using a macro to generate the scatterplots for the different thresholds separately (general code is below).
proc sgplot data=all_states_stats;
scatter x=Perc_unstable y=Perc_supp / group=state;
xaxis label = 'Percent unstable';
yaxis label = 'Percent suppressed';
where threshold=&threshold;
run;
However, I want to try to put everything on the same plot where the symbol represents the state and the colour represents the threshold. I've tried removing my where statement and adding a second group= (group=threshold) statement, but that only plots everything giving all states different colours, but no way to show which point is which threshold.
proc sgplot data=all_states_stats;
scatter x=Perc_unstable y=Perc_supp / group=state group=threshold;
xaxis label = 'Percent unstable';
yaxis label = 'Percent suppressed';
run;
Any help is appreciated. Thank you!
It sounds as if you may want to explore SGPANEL. It wouldn't give you everything on a single plot but it would give you everything grouped together.
In PROC SGPLOT, you can create attribute maps so that each state/threshold combination is assigned a specific color and symbol.
Of course, if you have 50 states and a dozen or two dozen thresholds, a scatterplot probably would lose visual information, as no one could visually process 50 different colors and two dozen markers. There is a limit to how many color/symbol combinations can be perceived by a viewer.
What you need is the ability to group separately by two classifiers, one for marker symbol, one for marker color. This is NOT supported for SCATTER plot, but IS supported in SERIES plot. You can use SERIES plot with markers and set line thickness=0. Then, you can use the GROUP, GROUPMC and GROUPMS to control the marker color and symbols separately. Remember to use a Style with Attrpriority=none, or set Attrpriority=none in the ODs Graphics statement to see the different marker symbols.
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: