SAS画图

330:SAS输出图形编号不正确(ods graphics)

2024-04-05  本文已影响0人  SASPRO的打工人生活

最近有一个读者问了一个问题,就是在用ods graphics输出图形的时候,文件名总是莫名其妙地多输出了1,比如明明在程序里面设置的是2-1,但是输出的时候却却变成了2-11。

ods graphics /reset imagename = "Output 2-1" imagefmt = png height = 3.33in width = 5in;

设置输出名字是通过下面这个选项

IMAGENAME="filename"

specifies the base image filename.If more than one image is generated, each is assigned a filename that consists of a base name followed by a number in order to create unique names. This numbering can be reset with the RESET=INDEX option.

于是我将reset的选项改成index,但是发现并没有什么用,还是会多输出1。

看SAShelp的一个例子

根据例子的解释,Output 2-1是“根名字”,第一次输出的名字就是Output 2-1,然后后续继续输出的话就是Output 2-11;Output 2-12这样子。

然后我们输出是通过ods graphics输出,这是一个destination,但是一般我们默认的输出路径是ods listing;ods html,相当于我们在用ods graphics输出图形之前,我们已经在ods listing或者ods html输出过一遍图形了。这就是为什么我们输出图形的时候会多了一个1,也可以看下面英文的解释:

you have two destinations open -- the default HTML destination that opens with the session and your LISTING destination. The HTML destination creates "spaghetti.png" and the LISTING destination creates "spaghetti1.png".

现在找出原因了,那么其实我们只需要在程序前面加上ODS _all_ close就可以了,相当于先把所有的输出目标关闭,只是再打开ods graphics,就能保证输出的图形名字是根名字了。

这也是我们在输出listing的时候用ods rtf输出,得先加上ods listing close的原因,因为你会先在listing这个输出目标先输出一遍,这个是极其占据内存的,尤其是你输出的是LB相关的listing。

ODS _all_ close;

ods listing gpath = "&test\graph" image_dpi = 300 style = aepanelstyle;

ods graphics /reset  imagename = "Output 2-1" imagefmt = png height = 3.33in width = 5in;

proc sgrender data = tfldata.adaesummary1 template = aedatapanelsoc;

  where trtan = 54 and aesoc in ("GENERAL DISORDERS AND ADMINISTRATION SITE CONDITIONS", "SKIN AND SUBCUTANEOUS TISSUE DISORDERS"); * The AESOC condition only outputs the first two SOCs;

  by trta;

  format order aefmt.;

run;

上一篇下一篇

猜你喜欢

热点阅读