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.
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.
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.
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.
Thank you!
I agree that Draw statements got a little "overdesigned". 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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.