Data visualization with SAS programming

PROC SGRENDER Annotate

Accepted Solution Solved
Reply
Super Contributor
Posts: 543
Accepted Solution

PROC SGRENDER Annotate

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.

Attachment

Accepted Solutions
Solution
‎08-12-2013 03:57 PM
SAS Super FREQ
Posts: 1,044

Re: PROC SGRENDER Annotate

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


All Replies
Solution
‎08-12-2013 03:57 PM
SAS Super FREQ
Posts: 1,044

Re: PROC SGRENDER Annotate

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.

Super Contributor
Posts: 543

Re: PROC SGRENDER Annotate

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!

SAS Super FREQ
Posts: 1,044

Re: PROC SGRENDER Annotate

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.

Post a Question
Discussion Stats
  • 3 replies
  • 788 views
  • 0 likes
  • 2 in conversation