Not with SAS 9.2. When you include a scatter plot with markerchar into the legend, you will get the swatch(s) in the legend of the same color as the markechar. This is true with any plot. With SAS 9.3 you have some new options. Or, you can use the vector plot idea I mentioned in #6 earlier.
Thanks! Have a nice weekend.
Maybe we got too wrapped up in the legend. All you really need is this. See INSET statement.
ods graphics / reset width=4in height=3in imagename='MeanMarker';
proc sgplot data=try1 noautolegend;
options orientation=landscape;
xaxis values=(0 to 4 by 1) label='Trt' ;
yaxis values=(-10 to 60 by 10) label="Something" ;
title "";
scatter x = trt y = value / markerattrs=(size=9 symbol=circle color=black) legendlabel="Individual Value" name="Ind";
scatter x = trt y = mean / MARKERCHAR=meanbar legendlabel="--- Mean" name="Mean";
scatter x = trt y = median / MARKERCHAR=mednbar legendlabel="xxx Median" name="Med";
inset ("--------" = "Mean" "- - - - -"="Median") / position=topright border;
/*keylegend "Ind" "Mean" "Med"/ title="" position=topright location=inside across=1 ;*/
run;
Dear Sunjay,
Thanks for the tip with the INSET statement (first, I left out the legend as I had same problem as John).
I think vector plot is also a good alternative. On the other hand, I liked the MARKERCHAR option, as it is easy to
use (here is an example of my graph):
Natalie
See article on blog
Dear Sanjay,
Many thanks for the detailed explanation and statment. I agree with Natalie. Maybe in the later version of SAS, some line types (e.g. solid line, dash line etc) could be considered to add into the symbol list. So the graph is even more flixable and powerful.
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.