I will take a step back from some of my usual advanced topics and discuss some of the most basic aspects of ODS Graphics: enabling, selecting, and displaying graphs. There are fundamentally two ways to make graphs using ODS Graphics.
You can enable ODS Graphics by specifying the ODS GRAPHICS ON statement. ODS Graphics might or might not be enabled by default. If you are running SAS in batch or line mode, ODS Graphics is probably not enabled by default. In most other cases, ODS Graphics is probably enabled by default. Rick Wicklin's post Is ODS graphics enabled? shows how to check if ODS Graphics is enabled.
The ODS GRAPHICS ON statement serves as a flag for analytical procedures that graphs are desired. In contrast, PROCs SGPLOT, SGSCATTER, SGPANEL, and SGRENDER only exist to produce graphs, so they produce graphs whether or not ODS Graphics is enabled. While you never need to enable ODS Graphics before running an SG procedure, you still might want to specify an ODS GRAPHICS statement because it provides a way for you to specify many options that apply to both the SG and analytic procedures.
Analytic procedures produce output besides graphs including tables and output data sets. Depending on what you are doing, you might or might not want to see graphs. You can specify ODS GRAPHICS OFF to suppress graphs and then enable graphics again later. Alternatively, most analytic procedures that produce graphs have a PLOTS=NONE option to suppress graphs. PLOTS=NONE provides a convenient way to suppress graphs for a single procedure step. ODS GRAPHICS OFF provides a convenient way to suppress graphs for multiple procedure steps.
SAS/STAT® documentation provides a list of over 100 Procedures That Support ODS Graphics. For SAS/STAT procedures, you can click each procedure link to see the graphs that each procedure produces. Navigate to what is usually the preceding section in each chapter. and you can also see a list of the tables that are produced. Navigate to the examples, and you will find a link for each example that provides the sample library code. Navigate to the Syntax section from the navigation bar at the top of the page then navigate to the PROC statement. You will see the PLOTS= option that controls which graphs are produced. Options usually include PLOTS=ALL and PLOTS=NONE. Most other PLOTS= options depend on the procedure. Some PLOTS= options are in statements other than the PROC statement. Examples include the BAYES statement in many procedures and the TABLES statement in PROC FREQ. Procedures such as PROC LIFETEST provide numerous options in the PLOTS= option. Others, such as PROC ANOVA, offer few options. Before attempting graph customization, see the procedure's syntax section; there might be an option that does what you want.
While the documentation provides lists of tables and graphs, they might not all come out in any particular analysis. (Specifying PLOTS=ALL will not force PROC GLM to produce an analysis of covariance plot when there is no covariate.) Usually, the easiest way to determine which tables and graphs are produced is to submit the following statement before running the procedure:
ods trace on;
Examine the SAS log to see which tables and graphs are produced. The following step produces all of the default output:
ods graphics on; ods trace on; proc reg data=sashelp.class; model weight=height; quit;
Tables include: NObs, ANOVA, FitStatistics, and ParameterEstimates. Graphs include: DiagnosticsPanel, ResidualPlot, and FitPlot. ODS Graphics and trace output are both enabled until you disable them.
If your data are too large to conveniently run through a preliminary analysis to gather output names, use the OBS= data set option or analyze a small random sample of the data first. Examples:
proc reg data=sashelp.heart(obs=5); model weight=height; quit; data heart; set sashelp.heart; if uniform(104) lt 0.001; * Select with probability 1 / 1000; run; proc reg data=heart; model weight=height; quit;
Note that the nature of the analysis can change with the number of observations. An analysis of the 6 observations in the random sample of the SASHELP.HEART data displays fit and residual plots, whereas an analysis of the full data set displays heat maps.
proc reg data=sashelp.class plots=all; model weight=height; quit;
PLOTS=ALL additionally displays the following graphs: ResidualHistogram, ResidualByPredicted, RStudentByPredicted, ObservedByPredicted, CooksDPlot, RStudentByLeverage, QQPlot, RFPlot, ResidualBoxPlot, DFFITSPlot, and DFBETASPanel.
You can use ODS SELECT and ODS EXCLUDE statements or the ODS document to control what specific output is produced. The following selects only the fit plot.
proc reg data=sashelp.class; ods select fitplot; model weight=height; quit;
The following excludes the diagnostic panel.
proc reg data=sashelp.class; ods exclude DiAgNoStIcSPAnel; model weight=height; quit;
Any mix of uppercase and lowercase (including the silly one in the preceding step) works for this type of ODS SELECT and EXCLUDE. That is not true for WHERE clauses. The following selects only tables or graphs that have 'Residual' in their name:
proc reg data=sashelp.class plots=all; ods select where=(_Name_ ? 'Residual'); model weight=height; quit;
The following selects only the graphs from the 'ObswiseStats' group:
proc reg data=sashelp.class plots=all; ods select where=(_Path_ ? 'ObswiseStats'); model weight=height; quit;
You can specify the following statement to suppress most tables and display most graphs for most procedures:
ods select where=(lowcase(_path_) ? 'plot' or lowcase(_path_) ? 'gram' or lowcase(_path_) ? 'panel' or lowcase(_path_) ? 'by' or lowcase(_path_) ? 'sg' or lowcase(_path_) ? 'map' or lowcase(_path_) ? 'curve' or lowcase(_path_) ? 'path' or lowcase(_path_) ? 'graph')(persist);
Notice that the syntax of these last three ODS SELECT statements compare character strings. The case must be the same for the two specifications to match. The combination of the LOWCASE function and all lowercase strings ensures proper matching. This selection WHERE clause persists until it is cleared. Specify ODS SELECT ALL to restore normal table and graph selection.
Graphs can appear in multiple destinations: LISTING, HTML, RTF, PRINTER, and so on. Graphs are expensive to produce, so do not create more than you need. Be aware of your open destinations. The following displays your open destinations.
proc print data=sashelp.vdest; run;
When ODS GRAPHICS is enabled and LISTING is your only open destination, you might not notice the graphs, but SAS still spends time and resources creating and storing them. If LISTING and HTML are both open, then you will create each graph twice. That is fine if that is what you want, but it is less efficient than creating a single graph. Say you are developing a program in the SAS windowing environment where the default destination is HTML and you use an ODS HTML statement to control the file name. Then if you later run that program in batch where LISTING is the default destination, you will needlessly make each graph twice. Alternatively, if the HTML destination is open by default and you also specify an ODS RTF statement, you will again create two graphs. The following step closes all destinations before opening the HTML destination:
ods _all_ close; ods html;
The following provide links to some other basic topics.
This is the introductory handout that we pass out conferences. An Overview of ODS Statistical Graphics in SAS 9.4
This is the primer in SAS/STAT documentation. A Primer on ODS Statistical Graphics