Data visualization with SAS programming

SGPLOT with 2 groups i.e. Color by Site and Shape by Treament

Reply
New Contributor
Posts: 4

SGPLOT with 2 groups i.e. Color by Site and Shape by Treament

Hi,

I was wondering if there was an elegant way to group by two variables in SGPLOT. For example I want to color by Site and Shape by Treatment. The only way I can see how that's possible at the moment is to have a lot of different Scatter statements using the unstacked variables but this is not elegant, and has too many items on the legend.

I've got an example here:
http://krissharris.co.uk/wp/wp-content/uploads/2011/02/Group-by-2-variables-sas.png

This is the code I used:

proc sgplot data = transpose_example2;
scatter x = Cohort_num y = Wake_Forest_F / markerattrs = (color = green symbol = asterisk);
scatter x = Cohort_num y = Wake_Forest_G / markerattrs = (color = green symbol = triangle);
scatter x = Cohort_num y = Wake_Forest_H / markerattrs = (color = green symbol = square);
scatter x = Cohort_num y = Wake_Forest_I / markerattrs = (color = green symbol = star);

scatter x = Cohort_num y = Leicester_F / markerattrs = (color = blue symbol = asterisk);
scatter x = Cohort_num y = Leicester_G / markerattrs = (color = blue symbol = triangle);
scatter x = Cohort_num y = Leicester_H / markerattrs = (color = blue symbol = square);
scatter x = Cohort_num y = Leicester_I / markerattrs = (color = blue symbol = star);


xaxis OFFSETMIN = 0.1 OFFSETMAX = 0.1;
yaxis label = "Response";
run;

Many thanks, in advance.
Ask a Question
Discussion stats
  • 0 replies
  • 252 views
  • 0 likes
  • 1 in conversation