SAS:PROC SGPLOT BY GROUP 自动文件名 [英] SAS: PROC SGPLOT BY GROUP auto file names

查看:51
本文介绍了SAS:PROC SGPLOT BY GROUP 自动文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 BY GROUP 选项绘制一些数据.虽然我可以使用 #byval 选项自动将 BY GROUP 值放在每个图的标题中,但我想单独保存每个图并想以 #byval 命名而不是调用它 - SGPLOT01、SGPLOT02 ...

例如假设我有:

数据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 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;

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 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);

这篇关于SAS:PROC SGPLOT BY GROUP 自动文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆