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 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 listing; goptions reset=all; proc greplay igout=work.gseg nofs; replay _all_; run; quit;
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 on the GREPLAY procedure, see The GREPLAY Procedure.
Replaying Output Using 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.
To create an ODS document for your output, do the following in your SAS program:
Open ODS DOCUMENT and specify the name of the output catalog with write permissions.
Close ODS LISTING.
Open the ODS destinations that you want to send your output to.
Specify the device that you want to use using the DEVICE= graphics option.
Generate your chart.
Close the ODS destinations that you opened in step 3.
Close ODS DOCUMENT.
Open ODS LISTING.
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); /* Close the LISTING destination */ ods listing close; /* 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 LISTING destination */ ods listing;
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 example:
Listing of: \Mygraphs.Mydocs\ Order by: Insertion Number of levels: All Obs Path Type ------------------------------------------------------- 1 \Gchart#1 Dir 2 \Gchart#1\Gchart#1 Graph 3 \Gchart#1\Gchart#2 Graph 4 \Gchart#1\Gchart#3 Graph
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:
Close the ODS LISTING destination.
Open the ODS destinations that you want to send the output to.
Use the DEVICE= graphics option to specify the graphics output device that you want to use to generate the graphs.
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.
Close the ODS destinations that you opened in step 2.
Open the ODS LISTING 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 listing 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 listing;
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 on using the ODS DOCUMENT destination and the DOCUMENT procedure, see SAS Output Delivery System: User's Guide.
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.