Wednesday, June 22, 2011

Introduction to ODS Graphics

With SAS 9.2, ODS Graphics is the new way to do graphs in SAS.  The goal of this blog is to make the reader aware of the features of this software, the various component parts and how you can use these most effectively in your work.

"ODS Graphics" is an umbrella term that includes many different aspects of the software as follows:
  1. A SAS programming language statement that can enable the creation of automatic graphs from SAS analytical procedures.
  2. The Graph Template Language (GTL) for creation of custom graphs.
  3. The Statistical Graphics (SG) Procedures for creation of commonly used graphs.
  4. The ODS Graphics Designer interactive application for creation of commonly used graphs.
1.  Automatic Graphs from SAS procedures:

You can get automatic graphs from SAS procedures without writing any additional graphics code.  To do that, you simply need to enable the ODS Graphics system, and the procedures will produce the appropriate graphs.  Many SAS procedures also support procedure options to control the graphs that are produced.

To enable ODS Graphics, simply use this statement before your procedure statements:
 
    ods graphics on;
    <procedure statements>
    ods graphics off;

Example:

    ods html;
    ods graphics on;

    ods select 'Analysis of Variance';
    ods select 'Fit Plot';

    proc reg data=sashelp.class;
       model Weight = Height;
       quit;

    ods graphics off; 
    ods html close;

Output:


Since ODS Graphics is on, the selected output, both table and graph are written to the open HTML destination. 

In the subsequent articles, I will introduce the Graph Template Language (GTL), the Statistical Graphics (SG) Procedures and the Interactive Designer application along with with examples.