在我们开始之前,让我们更好地了解当您运行PROC SGPLOT以及BY语句和SG注释数据集时会发生什么。这个例子为每个通过Sex运行PROC SGPLOT生成的图形添加了一个注释,单词“Students”。
proc sort data=sashelp.class out=c; by sex; run; data anno1; retain x1 20 y1 85 function 'Text' dataspace 'GraphPercent' width 100; label = 'Students'; output; run; proc sgplot data=c sganno=anno1 tmplout='tmp1.tmp'; scatter y=weight x=height; by sex; run;


不需要TMPLOUT =选项。但是,它显示了PROC SGPLOT编写的用于制作图形的模板。如果您真的想了解PROC SGPLOT的作用,您需要了解模板。它存储在文件tmp1.tmp中,如下所示(添加缩进后)。
proc template; define statgraph sgplot; dynamic __BYLINE__; begingraph / collation=binary; EntryTitle __BYLINE__ / textattrs=(size=GraphLabelText:fontsize); layout overlay / yaxisopts=(labelFitPolicy=Split) y2axisopts=(labelFitPolicy=Split); ScatterPlot X=Height Y=Weight / subpixel=off primary=true LegendLabel="Weight" NAME="SCATTER"; DrawText "Students" / X=20 Y=85 WIDTH=100;