The PROC Step

The descriptions in this topic refer to the example that is shown in A Typical Program.

About the PROC Step

A group of SAS procedure statements is called a PROC step.
The PROC step consists of the following:
  • a beginning procedure (PROC) as illustrated in line 4 in Typical SAS Program statement with options
  • typically, statements specifying plot types, variables, and options
  • an ending RUN as illustrated in line 9 in Typical SAS Program statement
These statements can identify and analyze the data in SAS data sets. They can generate the graphics output and control the appearance of the output. Statements can define variables and perform other operations on your data. You can also specify global statements and options within the PROC step.

Procedure Statements and Options

The procedure statement as illustrated in line 4 in Typical SAS Program identifies which procedure you are invoking, such as the SGPLOT procedure, the SGPANEL procedure, and so on.
The statement also specifies which input data set is to be used. A data set is not required for all of the procedures. For example, the SGRENDER procedure defaults to the most recently created SAS data set if none is provided. The SGDESIGN procedure defaults to the data set or data sets that are currently defined in the SGD file.
The statement can include options that are related to the procedure. For example, the DESCRIPTION= option can be used with several procedures to provide a description for the output image.

Plot Statements and Options

Plot statements are used within the procedure to identify the type of plot that you want the procedure to produce. The SGPLOT and SGPANEL procedures require at least one plot statement.
Multiple plot statements can be used, as shown in the example. A SERIES statement as illustrated in line 6 in Typical SAS Program is used to create a series plot that shows power generation from coal. A second SERIES statement creates a series plot that shows power generation from natural gas.
Options are available for specifying colors, marker symbols, and other attributes of plot features. In the example, both series plots specify that data labels are displayed. The second SERIES statement uses the Y2AXIS option to plot natural gas power output along the Y axis on the right side of the plot as illustrated in line 7 in Typical SAS Program.
The SGPLOT procedure also enables you to add a text inset to a plot using the INSET statement (not shown in the example). The INSET statement adds a text box within the axes of the plot. Options are available for specifying the visual attributes of the text box and the text.

(Optional) Legend Statement and Options

By default, legends are created automatically for some plots, depending on their content. The graph shown in the example has an automatically generated legend.
You can manually add a legend to the graph for the SGPLOT, SGPANEL, and SGSCATTER procedures. When you manually add a legend, options are available for specifying the legend title, its position in the graph, and other attributes.

(Optional) Axis Statements and Options

The SGPLOT and SGPANEL procedures contain statements that enable you to change the type and appearance for the axes of the graph. By default, the type of each axis is determined by the types of plots that use the axis and the data that is applied to the axis. You can change the type of axis that is used for a plot. For example, to display independent data values rather than a range of numeric values on the axis, specify the TYPE=DISCRETE option. (Not all plot types support discrete axes.)
The SGPLOT procedure supports the use of secondary axes, as shown in the example as illustrated in line 7 in Typical SAS Program. Secondary axes are denoted as X2 and Y2 axes. The secondary axes support the same options as the primary axes.
When you use an axis statement, options are available for showing or hiding axis features, such as ticks and labels, and for specifying other attributes. The graph shown in A Typical Program has three axis statements as illustrated in line 8 in Typical SAS Program. The first statement changes the X axis to be discrete. The other two statements change the labels for the Y and Y2 axes.

Other Required Statements

The SGPANEL and SGSCATTER procedures include some important statements that are not shown in the example. These statements are required with the procedure statement.
The SGPANEL procedure requires a PANELBY statement. This statement specifies one or more classification variables for the panel, the layout type, and other options for the panel. For more information, see PANELBY Statement.
The SGSCATTER procedure requires 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.
For more information, see Concepts: SGSCATTER Procedure.