Creating a Static Graphic

You can use a GOPTIONS statement with a device type of GIF, JPEG, SVG, or PNG to create a static graphic output file from one or more SAS/GRAPH procedures. SAS first creates a GRSEG entry in a graphics catalog in your WORK library, and then creates a graphics output file of the specified type from the GRSEG entry.
Follow these steps to generate one or more static graphs using the ODS LISTING destination:
  1. Add a FILENAME statement to create a file reference for the location of the output files. To generate only one output file, specify the file reference, filename, and storage location as follows:
    filename mygif1 "C:\mysas\images\barchart.gif"; /* Path to output file */
    The file reference can be up to eight characters in length. To generate multiple images in a single program, specify a file reference for the path only, as follows:
    filename imageout "C:\mysas\images"; /* Path to output directory */
    When you generate multiple image output files, the SAS/GRAPH software automatically generates the names of the graphics output files, as described in Summary of How Output Filenames and GRSEG Names Are Handled.
  2. Add a GOPTIONS statement to specify the output format using the DEVICE= graphics option, and the file reference using the GSFNAME= graphics option as follows:
    goptions reset=all device=gif  gsfname=mygif1;
    The value of the GSFNAME= graphics option is the name of your previously defined file reference, whether that file reference references a filename or a directory. If you do not specify a value for the GSFNAME= graphics option, the SAS/GRAPH software uses default names for your graphics output files as described in Summary of How Output Filenames and GRSEG Names Are Handled.
  3. Close the ODS HTML destination, and then open the ODS LISTING destination.
    ods html close;
    ods listing;
  4. Run the procedure that generates the graph. For example:
    proc gchart data=sashelp.class;
            hbar3d sex / sumvar=height type=mean;
     run;
    quit;
    The output is stored in the format specified by the DEVICE= graphics option, and in the output location specified by the GSFNAME= graphics option. For example, C:\mysas\images\barchart.gif.
  5. Close the ODS LISTING destination, and then open ODS HTML.
    ods listing close;
    ods html;
To create an HTML file that embeds the image, use the ODS HTML destination with the following options:
BODY=
The filename of the output HTML file (FILE= is a synonym for BODY=).
PATH=
The location (URL or file reference) of the HTML file and static graphic file.
GPATH=
The location of the graphics output file that is created.
Note: You must specify a value for the GPATH= option only if you specify the FILE= option as a complete path and filename, and you do not specify the PATH= option. If you specify FILE= as just a filename (and extension), and you specify PATH=, then both the HTML file and the graphics output file are written to the same location (as specified by PATH=.)
STYLE=
The style to be applied. If you do not specify a style, the default style is applied.
For complete information about these options, see SAS Output Delivery System: User's Guide.