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

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;
1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

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

View solution in original post

2 REPLIES 2
DanH_sas
SAS Super FREQ

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

cdorger
Fluorite | Level 6

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:

https://documentation.sas.com/?docsetId=grstatgraph&docsetTarget=p0ltl3z1z97jldn14vccmjnrhg2n.htm&do...

 

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 988 views
  • 0 likes
  • 2 in conversation