准备工作:创建如图所示的数据集,命名为finalplot(text是文本框里面的内容,position文本框的方式,ord没用,x_和y_是文本框的坐标,m1和n1是箭头的起始坐标,m2和n2是箭头的终点坐标,group是对文本框做了分类,这里用来填充不同的颜色)
proc sort data=final;by group text;run;
proc template;
define statgraph finalplot;
begingraph/datacolors=(lightblue white); /*指明填充不同的颜色*/
layout overlay /yaxisopts=(linearopts=(viewmin=0 viewmax=60) display=none)
xaxisopts=(linearopts=(viewmin=0 viewmax=50) display=none)
walldisplay=none;
textplot x=x_ y=y_ text=text /name="m"
contributeoffsets=none
position=position/*数据集中的变量,指明文本框的位置*/
splitpolicy=splitalways/*指明换行符是否一直生效,其他选项可能会出现部分不换行的情况*/
splitchar="*"/*指明换行符*/
splitjustify=auto/*与position结合使用,sas会自动选取对齐方式,这里实现不同的group居中和左对齐*/
splitchardrop=true/*是否扔掉换行符*/
vcenter=bbox
display=(fill outline)/*指明是否填充*/
group=group/*分组变量*/
/* fillattrs=graphdata1(color=lightblue transparency=0) *//*这里想实现不同组用不同的填充颜色的,但是没有成功,故采用了在上面的begingraph后添加命令*/
/* fillattrs=graphdata2(color=red transparency=0)*//*这里想实现不同组用不同的填充颜色的,但是没有成功,故采用了在上面的begingraph后添加命令*/
textattrs=(weight=bold color=black)/*字体设置*/
outlineattrs=(color=black);/*文本框框线颜色*/
vectorplot xorigin=m1 yorigin=n1 x=m2 y=n2 /xaxis=x/*箭头的始末位置变量*/
yaxis=y
arrowdirection=out
arrowheadshape=filled/*箭头的种类*/
lineattrs=(pattern=solid thickness=1px color=black);/*箭头设置*/
/* drawline x1=35 y1=25 x2=35 y2=10 /xaxis=x*/
/* yaxis=y */
/* drawspace=datavalue*/
/* lineattrs=(pattern=solid thickness=1px color=black);*//*这段代码可实现单独再画一条线*/
endlayout;
endgraph;
end;
run;
ods listing close;
ods graphics on / ANTIALIASMAX=9999 ;
ods rtf file="&&_orgOut&period.\&PgmNm..rtf" nogfootnote nogtitle;
proc sgrender data=final template=finalplot;
run;
ods graphics off;
ods rtf close;
ods listing;
最终结果如下