Plotting One Set of Variables

Understanding the PLOT Statement

The PLOT procedure produces two-dimensional graphs that plot one variable against

another within a set of coordinate axes. The coordinates of each point on the plot

correspond to the values of two variables. Graphs are automatically scaled to the values

of your data, although you can control the scale by specifying the coordinate axes.

You can create a simple two-dimensional plot for one set of measures by using the

following PLOT statement:

PROC PLOT <DATA=SAS-data-set>;

PLOT vertical*horizontal;

where vertical is the name of the variable to plot on the vertical axis and horizontal is the

name of the variable to plot on the horizontal axis.

By default, PROC PLOT selects plotting symbols. The data determines the labels for the

axes, the values of the axes, and the values of the tick marks. The plot displays the

following:

• the name of the vertical variable that is next to the vertical axis and the name of the

horizontal variable that is beneath the horizontal axis

• the axes and the tick marks that are based on evenly spaced intervals

• the letter A as the plotting symbol to indicate one observation; the letter B as the

plotting symbol if two observations coincide; the letter C if three coincide, and so on

• a legend with the name of the variables in the plot and meaning of the plotting

symbols

The following display shows the axes, values, and tick marks on a plot.

Figure 30.2 Diagram of Axes, Values, and Tick Marks

vertical

axis

horizontal axis

value

tick marks

20

10

2 4 8 10 12

Note: PROC PLOT is an interactive procedure. After you issue the PROC PLOT

statement, you can continue to submit any statements that are valid with the

Plotting One Set of Variables 535

procedure without resubmitting the PROC statement. Therefore, you can easily and

quickly experiment with changing labels, values for tick marks, and so on.

Example

The following program uses the PLOT statement to create a simple plot that shows the

trend in high Dow Jones values from 1968 to 2008:

proc plot data=highlow;

plot DowJonesHigh*Year;

title 'Dow Jones Industrial Average Yearly High';

run;

The following output shows the plot:

Figure 30.3 Using a Simple Plot to Show Data Trends

The plot graphically depicts the exponential trend in the high value of the Dow Jones

Industrial Average over the past 50 years. The greatest growth has occurred in the past

10 years, increasing by almost 6,000 points.

536 Chapter 30 • Plotting the Relationship between Variables

Start Free Trial

No credit card required