|Statistical Graphics Using ODS|
|Naming Graphics Image Files|
The following discussion applies to the destinations where ODS graphs are created as individual image files (for example, HTML, LISTING, and LATEX). The names of graphics image files are determined by a base file name, an index counter, and an extension. By default, the base file name is the ODS graph name (see the section Determining Graph Names and Labels). There is an index counter for each base file name. The extension indicates the image file type. The first time a graph object with a given base file name is created, the file name consists only of the base file name and the extension. If a graph with the same base file name is created multiple times, then an index counter is appended to the base file name 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 graphics image files 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 zero, and one is added each time the same name is used. Note, however, that when the index is at zero, it is not added to the file name.
You can specify the RESET=INDEX option 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 the RESET=INDEX option in the ODS GRAPHICS statement. Graphics image files with the same name are overwritten.
You can specify a base file name for all your graphics image files with the IMAGENAME= option in the ODS GRAPHICS statement as follows:
ods graphics on / imagename="MyName";
You can also specify the RESET=INDEX option as follow:
ods graphics on / reset=index imagename="MyName";
The IMAGENAME= option overrides the default base file name. With the preceding statement, the graphics image files are named MyName, MyName1, MyName2, and so on.
You can specify the image file type for the LISTING, HTML, or LATEX destinations with the IMAGEFMT= option in the ODS GRAPHICS statement as follows:
ods graphics on / imagefmt=gif;
For more information, see the section ODS GRAPHICS Statement.
Since the index counter depends only on the base file name, 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 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;