Chapter 33: The PLOT Procedure


Overview: PLOT Procedure

The PLOT procedure plots the values of two variables for each observation in an input SAS data set. The coordinates of each point on the plot correspond to the two variables values in one or more observations of the input data set.

Output 33.1 is a simple plot of the high values of the Dow Jones Industrial Average (DJIA) between 1954 and 1994. PROC PLOT determines the plotting symbol and the scales for the axes. These are the statements that produce the output:

 options nodate pageno=1 linesize=64     pagesize=25;  proc plot data=djia;     plot high*year;     title 'High Values of the Dow Jones';     title2 'Industrial Average';     title3 'from 1954 to 1994';  run; 
Output 33.1: A Simple Plot
start example
 High Values of the Dow Jones               1                       Industrial Average                       from 1954 to 1994      Plot of High*Year. Legend: A = 1 obs, B = 2 obs, etc.  4000 +                                             A                                                   A                                                 AA  High                                       A  A                                              A                                             A  2000 +                                     A                                           A                                         AA                      AAAAAAAAAAAAAAAAAAA              AAAAAAAA            AA     0 +       ---+---------+---------+---------+---------+---------+--       1950      1960      1970      1980      1990      2000                                 Year 
end example
 

You can also overlay two plots, as shown in Output 33.2. One plot shows the high values of the DJIA; the other plot shows the low values. The plot also shows that you can specify plotting symbols and put a box around a plot. The statements that produce Output 33.2 are shown in Example 3 on page 650.

Output 33.2: Plotting Two Sets of Values at Once
start example
 Plot of Highs and Lows                     1               for the Dow Jones Industrial Average             Plot of High*Year. Symbol used is '*'.             Plot of Low*Year. Symbol used is 'o'.       ---+---------+---------+---------+---------+---------+--- 4000 +                                              *        +                                                    *                                                            * o                                                          *oo           High                                           *                                                           **                                                              o                                                          *oo               2000 +                                     * o               +                                             o                                                           *o                                                          **o                                        ****** ************oo                                    *****oooooo*o o oooooooo                                 *****oooo           o                                         o                                                      0 +                                                       +       ---+---------+---------+---------+---------+---------+---       1950      1960      1970      1980      1990      2000                                 Year  NOTE: 7 obs hidden. 
end example
 

PROC PLOT can also label points on a plot with the values of a variable, as shown in Output 33.3. The plotted data represents population density and crime rates for selected U.S. states. The SAS code that produces Output 33.3 is shown in Example 11 on page 670.

Output 33.3: Labeling Points on a Plot
start example
 A Plot of Population Density and Crime Rates                                   1                         Plot of Density*CrimeRate$State. Symbol is value of State.          ---+------------+------------+------------+------------+------------+------------+------------+--- Density                                                                                                       500 +                                                                                                +                                                                                                                                                                Maryland                                                                                                     M                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Delaware                                                                                                     D                                                                            Pennsylvania           Ohio                                                                                    P                  O                                                                 250 +                                                                                                +                                                     Illinois                                                                                                     I                                     Florida                                                                                                       F                                               North Carolina              California                                                         New                   South                C                                             West          Hampshire   Alabama N   Carolina                                                           Virginia            N                T     S        G Georgia                                                W           Mississippi       A Tennessee                  Washington Texas                                                M  Vermont V    M Missouri     Oklahoma       W        T                                    South          Arkansas A    M Minnesota        O         Oregon                                          Dakota                 I Idaho                    Nevada    O                                    0 +         S N  North Dakota                                 N                                    +          ---+------------+------------+------------+------------+------------+------------+------------+---          2000         3000         4000         5000         6000         7000         8000         9000                                                      CrimeRate 
end example
 



Base SAS 9.1.3 Procedures Guide (Vol. 1)
Base SAS 9.1 Procedures Guide, Volumes 1, 2, 3 and 4
ISBN: 1590472047
EAN: 2147483647
Year: 2004
Pages: 260

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net