例如假设我有:数据xyz;输入类型$ x y1 y2@@;牌;1 5 72 7 93 8 10乙 1 5 7乙 2 7 9乙 3 8 10;;跑步;PROC SGPLOT 数据=xyz;按类型;系列1 x=x y=y1/标记;系列2 x=x y=y2/标记;标题#byval";跑步;在本例中,将为类型 A 和 B 分别创建两个图.但程序会自动将它们命名为 SGPLOT1.pdf 和 SGPLOT2.pdf.我宁愿将它们命名为 A.pdf 和 B.pdf,并希望将它们保存到目录C:/SGPLOTS/".感谢您的帮助. 解决方案 一种选择是使用 ODS 并使用宏分别打印每个 TYPE,如下例所示.数据xyz;输入类型$ x y1 y2 @@;牌;1 5 72 7 93 8 10乙 1 5 7乙 2 7 9乙 3 8 10;跑步;ods 列表关闭;%macro plot_it(type=);选项重置设备 = saprtc目标 = saprtc;ods pdf file="C:/SGPLOTS/&type..pdf" notoc;PROC SGPLOT 数据=xyz;按类型;where type = "&type";系列 x=x y=y1/标记;系列 x=x y=y2/标记;标题#byval";跑步;ods pdf 关闭;% 修正 plot_it;%plot_it(type=A);%plot_it(type=B);I am plotting some data using BY GROUP option. While I am able to use #byval option to automatically put BY GROUP value in title of each plot, but I want to save each plot individually and want to name it after #byval instead of calling it - SGPLOT01, SGPLOT02 ...e.g. Lets say I have:data xyz;input type$ x y1 y2@@;cards;A 1 5 7A 2 7 9A 3 8 10B 1 5 7B 2 7 9B 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;In this example, two plots will be created one each for type A and B. But program will automatically name them as SGPLOT1.pdf and SGPLOT2.pdf. I would rather want to name them A.pdf and B.pdf, and want to save them to directory "C:/SGPLOTS/".Thanks for your help. 解决方案 One option is to use ODS and put use a macro to print each TYPE separately, like in the following example.data xyz;input type$ x y1 y2 @@;cards;A 1 5 7A 2 7 9A 3 8 10B 1 5 7B 2 7 9B 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); 这篇关于SAS:PROC SGPLOT BY GROUP 自动文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-20 13:35
查看更多