Basic Structure of a Typical Procedure

In general, an ODS Graphics procedure contains a procedure statement and one or more plot statements. The procedure statement typically specifies a data set. A procedure can have optional statements, such as axis statements and ODS statements. This section shows typical syntax for the SGPLOT, SGPANEL, and SGSCATTER procedures. (The SGDESIGN procedure is discussed in Using SGD Files with the SGDESIGN Procedure. The SGRENDER procedure is shown in Using the Graph Template Language .)

The SGPLOT Procedure

Here is a typical SGPLOT procedure. The procedure requires a procedure statement and at least one plot statement. Both statements accept options that provide more control over the appearance or behavior of the output. In this example, the GROUP= option is used to group the data and make it easier to interpret (when viewed in a color medium).
proc sgplot data=sashelp.class;           /* procedure statement */
  scatter x=height y=weight / group=sex;  /* plot statement with a group option*/
run;
Output for the SGPLOT Procedure
Output for the SGPLOT Procedure

The SGPANEL Procedure

Here is a typical SGPANEL procedure, which creates a panel of graph cells for the values of one or more classification variables. The procedure requires a procedure statement, a classification statement (PANELBY), and at least one plot statement.
proc sgpanel data=sashelp.class;         /* procedure statement */
  panelby sex;                           /* classification statement */
  scatter x=height y=weight;             /* plot statement */
run;
Output for the SGPANEL Procedure
Output for the SGPANEL Procedure

The SGSCATTER Procedure

Here is a typical SGSCATTER procedure, which creates a paneled graph of scatter plots for multiple combinations of variables, depending on the layout statement that you use. The procedure requires a procedure statement and one of these three statements:
PLOT creates a paneled graph of scatter plots where each graph cell has its own independent set of axes.
COMPARE creates a shared axis panel, also called an MxN matrix.
MATRIX creates a scatter plot matrix.
This example plots the values of two combinations of Y and X variables and produces a separate cell for each combination. That is, each Y*X pair is plotted on a separate set of axes.
proc sgscatter data=sashelp.cars;           /* procedure statement */
  plot mpg_highway*weight msrp*horsepower;  /* plot statement */
run;
Output for the SGSCATTER Procedure
Output for the SGSCATTER Procedure