Is there a way to place a marker symbol on a graph using the Graph Template language analogous to the SAS/Graph annotate facility function="SYMBOL"? I want to make a custom legend for a plot and I am using a LAYOUT GRIDDED to place two rows: "<65 Years" and ">=65 Years". I want to place the markers used on the graph before this text. I know you can use DRAWOVAL and BEGINPOLYGON to create shapes but this is complicated and does not look exactly like the marker symbols. Is there a font that would give me access to the markers I use in the plot so that I can place them as a single character? I am using version 9.4.
This works but is awkward and the triangle does not look exactly like the filledtriangle plot marker:
*Draw the symbol/text for the first line of the legend;
drawoval x=89 y=90 width=5 height=5 /xspace=graphpercent yspace=graphpercent anchor=left widthunit=pixel
heightunit=pixel display=(fill) fillattrs=(color=darkblue) transparency=0;
drawtext "<65 Years" / xspace=graphpercent yspace=graphpercent anchor=left width=15 widthunit=percent x=90 y=90;
*Draw the symbol/text for the second line of the legend;
beginpolygon x=&x0 y=&y0 / xspace=graphpercent yspace=graphpercent transparency=0 display=(fill) fillattrs=(color=darkred);
draw x=&x1 y=&y0;
draw x=&x2 y=&y1;
endpolygon;
drawtext {unicode "2265"x} "65 Years" / xspace=graphpercent yspace=graphpercent anchor=left width=15 widthunit=percent x=90 y=87;
Instead of using annotation, try using the LEGENDITEM functionality instead. Here is a blog post from Sanjay on how it can be used: https://blogs.sas.com/content/graphicallyspeaking/2017/10/27/legend-items/
Hope this helps!
Dan
Instead of using annotation, try using the LEGENDITEM functionality instead. Here is a blog post from Sanjay on how it can be used: https://blogs.sas.com/content/graphicallyspeaking/2017/10/27/legend-items/
Hope this helps!
Dan
Dan, thanks for this suggestion, it worked really well. I was constructing my plot with the GTL so I used the LEGENDITEM statement with the DISCRETELEGEND statement rather than LEGENDITEM/KEYLEGEND as in Sanjay's blog post. It allowed the ability to place markers and text even with a default legend suppressed. And even with the lattice layout, I was able to place it exactly where I wanted, it works with UNICODE text, get an opaque background, a box around it...everything the client wanted!
I browsed Sanjay's posts but also found a short, simple example in the SAS® 9.4 Graph Template Language: Reference, Fifth Edition, LEGENDITEM statement:
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.