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

Hi.

I would like to draw two arrows on a plot that I created using PROC TEMPLATE + PROC SGRENDER:

proc template;
define statgraph foo;
begingraph / designwidth=800 designheight=1000;

entrytitle halign=center "Some title" / textattrs=(size=18 color = red );

   layout lattice / rowdatarange=data columndatarange=data rowgutter=10 columngutter=10;
      layout overlay / xaxisopts=( display=(LINE) )
yaxisopts=(type = linear linearopts = (viewmin=0 viewmax=200)tickvalueattrs=(size=18 )
griddisplay=off label=('Some axis title'));
         barchart x=sex y=age / barwidth=0.95 groupdisplay=Cluster clusterwidth=0.85 ;
      endlayout;
   endlayout;
endgraph;
end;
run;
ods listing gpath="\\.." image_dpi=150;
ods graphics / reset imagename = "simple_bar";

proc sgrender data = sashelp.class template=foo;
run;

Attached is what I would like to get.

Is there a way to annotate these arrows?

(I know the data doesn't make any sense, but just wanted to provide an example).

Thank you, as always!

Anca.


simple_bar.png
1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

Yes, there is with SAS 9.3.  You can use the DRAWARROW statements to create these annotations.  You can compute the dimensions into macro variables, and use that in the template.

With SAS 9.4, you can use SGANNOTATE with proc SGRENDER to render annotations from SAS data sets just like in SGPLOT.

View solution in original post

3 REPLIES 3
Jay54
Meteorite | Level 14

Yes, there is with SAS 9.3.  You can use the DRAWARROW statements to create these annotations.  You can compute the dimensions into macro variables, and use that in the template.

With SAS 9.4, you can use SGANNOTATE with proc SGRENDER to render annotations from SAS data sets just like in SGPLOT.

AncaTilea
Pyrite | Level 9

Thank you, Sanjay,

I finally got it to work.

It is not the most intuitive to me what is the wallpercent but for the longest time I kept getting "out of bounds" error.

drawarrow x1="10"  y1=1.25 x2="40" y2=1.25 /

          x1space=wallpercent y1space=datavalue

           x2space=wallpercent y2space=datavalue

           arrowheadshape=filled lineattrs=(color=red) ;

The bolded statement, once I get them to work make sense.

Smiley Happy

Thank you!

Jay54
Meteorite | Level 14

I agree that Draw statements got a little "overdesigned".  Smiley Wink  It was necessary to fully support SGANNOTATE.  SGPLOT basically scripts out DRAW statements for the annotations in the generated GTL template.

With SAS 9.4, SGRENDER supports SGANNO.  This will allow a consistent way to do such small additions to the graph using a separate SGANNO data set.  My goal is that annotate should be needed only for such small customizations, and not to build entire graphs.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 3 replies
  • 2546 views
  • 0 likes
  • 2 in conversation