SAS,情节标题
SAS, plot title
如何让标题成为"var1=e and var=b",假设它是一个重复程序(不能硬编码)。
data test1;
input y x var1$ var2$ key$;
datalines;
1 2 e b eb
2 4 e b eb
3 6 e b eb
4 1 e b eb
5 2 e b eb
6 3 e b eb
;
run;
proc sgplot data=test1 ;
series x=x y=y ;
title "I cannot make the title dynamic";
run;
将 VAR1 和 VAR2 的值读入宏,然后在标题中使用该宏。
proc sql noprint;
select var1, var2
into :var1 trimmed, :var2 trimmed
from test1(obs=1);
quit;
proc sgplot data=test1 ;
series x=x y=y ;
title "VAR1=&var1 and VAR2=&var2";
run;
特殊标题标记 #BYVAR<n>
和 #BYVAL<n>
被 n-th 替换为变量名及其当前分组值。此替换作为生成输出的过程中 by
组处理的一部分自动发生。
此示例演示如何关闭默认 by-lines 并使用特殊标记在输出标题中生成所需的叙述。
data cars;
Wheels = 4;
set sashelp.cars;
run;
options nobyline;
title "#byvar1=#byval1 and #byvar2=#byval2";
proc sgplot data=cars;
by wheels make;
vbar model / response=horsepower nostatlabel;
run;
options byline;
title;
如何让标题成为"var1=e and var=b",假设它是一个重复程序(不能硬编码)。
data test1;
input y x var1$ var2$ key$;
datalines;
1 2 e b eb
2 4 e b eb
3 6 e b eb
4 1 e b eb
5 2 e b eb
6 3 e b eb
;
run;
proc sgplot data=test1 ;
series x=x y=y ;
title "I cannot make the title dynamic";
run;
将 VAR1 和 VAR2 的值读入宏,然后在标题中使用该宏。
proc sql noprint;
select var1, var2
into :var1 trimmed, :var2 trimmed
from test1(obs=1);
quit;
proc sgplot data=test1 ;
series x=x y=y ;
title "VAR1=&var1 and VAR2=&var2";
run;
特殊标题标记 #BYVAR<n>
和 #BYVAL<n>
被 n-th 替换为变量名及其当前分组值。此替换作为生成输出的过程中 by
组处理的一部分自动发生。
此示例演示如何关闭默认 by-lines 并使用特殊标记在输出标题中生成所需的叙述。
data cars;
Wheels = 4;
set sashelp.cars;
run;
options nobyline;
title "#byvar1=#byval1 and #byvar2=#byval2";
proc sgplot data=cars;
by wheels make;
vbar model / response=horsepower nostatlabel;
run;
options byline;
title;