Replaying Your SAS/GRAPH Output

You can use the GREPLAY procedure or the ODS DOCUMENT destination and the DOCUMENT procedure to replay your SAS/GRAPH output.

Replaying Your Output Using the GREPLAY Procedure

For the SAS/GRAPH procedures that support GRSEGs, you can use the GREPLAY procedure to replay your graph GRSEGs without having to rerun your DATA step and procedures. You can replay all of your graphs or only the ones that you select. When you replay your graphs, use the same device that you used when you generated the original graphs. If you use a different device, your replayed graphs might be distorted.
You can replay your graphs to the GRAPH window for viewing or to a graphics output file. Here is an example that replays all of the graphs in the WORK.GSEG catalog to the GRAPH window for viewing:
ods html close;
ods listing;
goptions reset=all;
proc greplay igout=work.gseg nofs;
   replay _all_;
run;
quit;
ods listing close;
ods html;
You can also use the GREPLAY procedure to replay multiple graphs to a single file for the graphic and document formats that support multiple images per file. See Using the GREPLAY Procedure to Store Multiple Graphs in One Graphics Output File and Generating Web Animation with GIFANIM.
For information about the GREPLAY procedure, see GREPLAY Procedure.

Replaying Output Using the DOCUMENT Procedure

About the DOCUMENT Procedure

For all of the SAS/GRAPH procedures, you can use the DOCUMENT procedure to replay output that you created. Use the ODS DOCUMENT destination, without having to rerun your DATA step and procedures. The ODS DOCUMENT destination creates ODS output objects for your output. You can replay the output objects at any time to your monitor or to a different device.

Creating Your ODS Document

To create an ODS document for your output, do the following in your SAS program:
  1. Open ODS DOCUMENT and specify the name of the output catalog with Write permissions.
  2. Close ODS HTML.
  3. Open the ODS destinations that you want to send your output to.
  4. Specify the device that you want to use using the DEVICE= graphics option.
  5. Generate your chart.
  6. Close the ODS destinations that you opened in step 3.
  7. Close ODS DOCUMENT.
  8. Open ODS HTML.
Here is an example that shows how to create an ODS document containing three pie charts and how to store it in catalog Mygraphs.Mydocs. The pie charts are generated with the JAVA device.
/* Create the Mygraphs catalog */
LIBNAME Mygraphs "./";

/* Open the DOCUMENT destination. Specify catalog */
/* Mygraphs.Mydocs for the output and give it write permission */
ods document name=Mygraphs.Mydocs(write);

/* Open the HTML destination, and specify the JAVA device. */
ods html style=seaside;
goptions reset=all device=java;

/* Generate the charts */
proc gchart data=sashelp.cars gout=Mygraphs.Mydocs;
   pie Make / other=2;
      title1 "30 MPG or Better";
      where MPG_Highway >= 30;
   run;
   pie Make / other=3;
      title1 "Between 20 MPG and 29 MPG";
      where MPG_Highway < 30 and MPG_Highway >=20;
   run;
   pie Make / other=3;
      title1 "19 MPG or less";
      where MPG_Highway < 20;
   run;
quit;

/* Close the HTML and DOCUMENT destinations */
ods html close;
ods document close;

/* Reopen the HTML destination */
ods html;

Replaying Your ODS Document

After you create your ODS document, use the DOCUMENT procedure to replay it. You can replay all of the graphs in your document or only those that you select. To see a list of the graphs in an ODS document, use a LIST statement with the DOCUMENT procedure. Here is an example that shows how to list the graphs in Mygraphs.Mydocs.
proc document name=Mygraphs.Mydocs;
    list / levels=all;
run;
quit;
A list of the graphs in the document is displayed in the Output window as shown in the following figure.
List of Files in ODS Document Mygraphs.Mydocs
In this example, the graphs are listed in the order in which they were inserted into the catalog. To replay individual graphs, you must know the path to the graphs, which is shown in the Path column.
To replay the output:
  1. Close the ODS HTML destination.
  2. Open the ODS destinations that you want to send the output to.
  3. Use the DEVICE= graphics option to specify the graphics output device that you want to use to generate the graphs.
  4. Run the DOCUMENT procedure with one or more REPLAY statements to replay your graphs. Specify the path to each graph, and use the DEST= option to specify the output destination.
    Note: If you want to display all of the graphs, do not specify a path.
  5. Close the ODS destinations that you opened in step 2.
  6. Open the ODS HTML destination.
Here is an example that shows how to play the first and the third graphs in the Mygraphs.Mydocs catalog to the ODS RTF destination using the ACTIVEX device.
goptions reset=all device=activex;
ods html close;
ods rtf style=money;
proc document name=Mygraphs.Mydocs;
   replay \Gchart#1\Gchart#1 / levels=all dest=rtf;
   replay \Gchart#1\Gchart#3 / levels=all dest=rtf;
   run;
quit;
ods rtf close;
ods html;
To replay all of the graphs in the catalog, use one REPLAY statement that does not specify a path. For example:
proc document name=Mygraphs.Mydocs;
   replay / levels=all dest=rtf;
   run;
For more information about using the ODS DOCUMENT destination and the DOCUMENT procedure, see SAS Output Delivery System: User's Guide.