1
votes

I'm making several png image using sgplot and the by statement like this:

ods html path="&graphPath" body="index.html"
    image_dpi=300 style=sciensano1 device=png;

ods graphics on / reset noborder imagename="boom"
    height=10cm width=16cm ;

title;footnote;
options byline;
proc sgplot data=sashelp.class;
    histogram height;
    by Sex;
    run;quit;

ods html close;

This creates 1 html file (index.html)
and 2 png files (boom1.png & boom3.png)

I'm wondering if it's possible to name the png files according to the by values. Similarly as adding #byval in the title for example.

Currently, number are added automatically to the imagename from the ods graphics, I would like to get rid of the numbers and use the byval instead.

The only solution I have so far is to make all graphs individually, using a %do loop in a macro, this way I can parametrize the imagename and give it a macro variable name. The problem with that is that it's much more complex to implement and much slower.

EDIT: Using SAS 9.3

2

2 Answers

1
votes

In my SAS 9.4M4, there is no such feature in SGPLOT HISTOGRAM options, nor in ODS GRAPHICS IMAGENAME or INDEX.

Ideally, a future release would see ODS honor #BYVAL and #BYVAR substitution options.

ods graphics / imagename="boom#byval1";       * not real;
ods graphics / imagename="boom#byval(sex)";   * not real;

or

ods graphics / imagename="boom" reset=index(#byval1); * not real;

Fall back:

The GCHART Procedure statements, such as VBAR support the name= option which honors the #BYVAL substitution option.

vbar height / name="basename#byval1";  * creates gfx file whose name contains the by var value;
0
votes

Looks like this feature is in v9.4M5--dig it: Keeping Up To Date With ODS Graphics.