Plotting the Relationship between 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>;
|
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.
Diagram of Axes, Values, and Tick Marks
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 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 1954 to 1998:
options pagesize=40 linesize=76 pageno=1 nodate; proc plot data=highlow; plot DowJonesHigh*Year; title 'Dow Jones Industrial Average Yearly High'; run;
The following output shows the plot:
Using a Simple Plot to Show Data Trends
Dow Jones Industrial Average Yearly High 1 Plot of DowJonesHigh*Year. Legend: A = 1 obs, B = 2 obs, etc. DowJonesHigh | | 10000 + | | A | | A 8000 + | | | | A 6000 + | | A | | 4000 + A | AA | A | A AA | 2000 + A A | A | AA A AAAAA | AAAAAAAAAAAAA AA AAA | AAAAA 0 + | ---+---------+---------+---------+---------+---------+-- 1950 1960 1970 1980 1990 2000 YearThe plot graphically depicts the exponential trend in the high value of the Dow Jones Industrial Average over the last 50 years. The greatest growth has occurred in the last 10 years, increasing by almost 6,000 points.
Copyright © 2012 by SAS Institute Inc., Cary, NC, USA. All rights reserved.