我正在使用分组选项绘制一些数据。虽然我可以使用#byval选项自动将组值放入每个绘图的标题中,但我想要单独保存每个绘图,并希望以#byval命名它,而不是将其命名为- SGPLOT01,SGPLOT02 ...
比方说我有:
data xyz;
input type$ x y1 y2@@;
cards;
A 1 5 7
A 2 7 9
A 3 8 10
B 1 5 7
B 2 7 9
B 3 8 10
;;
RUN;
PROC SGPLOT DATA=xyz;
by type;
series1 x=x y=y1/markers;
series2 x=x y=y2/markers;
title "#byval";
RUN;在本例中,将为类型A和类型B创建两个绘图,但程序会自动将它们命名为SGPLOT1.pdf和SGPLOT2.pdf。我更愿意将它们命名为A.pdf和B.pdf,并希望将它们保存到"C:/SGPLOTS/“目录中。
谢谢你的帮助。
发布于 2012-02-29 08:07:41
一种选择是使用ODS和put,使用宏分别打印每种类型,如下面的示例所示。
data xyz;
input type$ x y1 y2 @@;
cards;
A 1 5 7
A 2 7 9
A 3 8 10
B 1 5 7
B 2 7 9
B 3 8 10
;
RUN;
ods listing close;
%macro plot_it(type=);
goptions reset
device = sasprtc
target = sasprtc
;
ods pdf file="C:/SGPLOTS/&type..pdf" notoc;
PROC SGPLOT DATA=xyz;
by type;
where type = "&type";
series x=x y=y1/markers;
series x=x y=y2/markers;
title "#byval";
RUN;
ods pdf close;
%mend plot_it;
%plot_it(type=A);
%plot_it(type=B);发布于 2014-02-08 01:32:06
您希望在#BYVAL之后的括号中添加变量名。在本例中,您希望在标题中添加#byval(type)。
我将您的示例放在SAS称为"HTML三明治“的东西中,即顶部两行,底部两行。此外,我还添加了helpbrowser选项,该选项告诉SAS使用自己的功能来显示html输出。
option helpbrowser=sas;
/**** top of html sandwich *****/
ods html ;
ods graphics on;
/*******************************/
data xyz;
input type$ x y1 y2@@;
cards;
A 1 5 7
A 2 7 9
A 3 8 10
B 1 5 7
B 2 7 9
B 3 8 10
;;
RUN;
PROC SGPLOT DATA=xyz;
by type;
series x=x y=y1/markers;
series x=x y=y2/markers;
title "Here is the type: #byval(type)";
RUN;
/**** bottom of html sandwich *****/
ods graphics off;
ods html close;
/**********************************/https://stackoverflow.com/questions/9485769
复制相似问题