The following discussion applies to the destinations where ODS graphs are created as individual image files (for example, HTML and LISTING). The names of graphic image files are determined by a base filename, an index counter, and an extension. By default, the base filename is the ODS graph name (see the section Determining Graph Names and Labels). There is an index counter for each base filename. The extension indicates the image file type. The first time a graph object that has a particular base filename is created, the filename consists only of the base filename and the extension. If a graph that has the same base filename is created multiple times, then an index counter is appended to the base filename to avoid overwriting previously created images.
To illustrate, consider the following statements:
proc kde data=bivnormal; ods select ContourPlot SurfacePlot; bivar x y / plots=contour surface; run;
If you run this step at the beginning of a SAS session, the two graphic image files that are created are ContourPlot.png
and SurfacePlot.png
. If you immediately rerun these statements, then ODS creates the same graphs in different image files named ContourPlot1.png
and SurfacePlot1.png
. The next time, the image files are named ContourPlot2.png
and SurfacePlot2.png
. The index starts at 0, and 1 is added each time the same name is used. However, if the index is at 0, then 0 is not included
in the filename.
You can specify RESET=INDEX in the ODS GRAPHICS statement to reset the index counter. This is useful when you need to have predictable names. It is particularly useful when you are running a SAS program multiple times in the same session. The following statement resets the index:
ods graphics on / reset=index;
The index counter is reinitialized at the beginning of your SAS session or if you specify RESET=INDEX in the ODS GRAPHICS statement. Graphic image files that have the same name are overwritten.
You can specify a base filename for all your graphic image files by using the IMAGENAME= option in the ODS GRAPHICS statement as follows:
ods graphics on / imagename="MyName";
You can also specify RESET=INDEX as follows:
ods graphics on / reset=index imagename="MyName";
The IMAGENAME= option overrides the default base filename. In the preceding statement, the graphic image files are named MyName
, MyName1
, MyName2
, and so on.
You can specify the image file type for the LISTING, HTML, or LATEX destination by specifying OUTPUTFMT= in the ODS GRAPHICS statement as follows:
ods graphics on / outputfmts=gif;
For more information, see the section ODS GRAPHICS Statement.
Because the index counter depends only on the base filename, if you specify multiple ODS destinations for your output, then
the index counter is increased independently of the destination. For example, the following statements create image files
named ContourPlot.png
and SurfacePlot.png
that correspond to the LISTING destination and ContourPlot1.png
and SurfacePlot1.png
that correspond to the HTML destination:
ods listing; ods html; ods graphics on / reset; proc kde data=bivnormal; ods select ContourPlot SurfacePlot; bivar x y / plots=contour surface; run; ods _all_ close; ods listing;
When you specify one of the destinations in the PRINTER family or the RTF destination, your ODS graphs are embedded in the
document, so the index counter is not affected. For example, the following statements create the image files ContourPlot.png
and SurfacePlot.png
for the LISTING destinations but no image files for the RTF destination:
ods listing; ods rtf; ods graphics on / reset; proc kde data=bivnormal; ods select ContourPlot SurfacePlot; bivar x y / plots=contour surface; run; ods _all_ close;