PLOT Procedure

Example 10: Excluding Observations That Have Missing Values

Features:

PROC PLOT statement option:: NOMISS

Data set: EDUCATION
This example shows how missing values affect the calculation of the axes.

Program

options formchar="|----|+|---+=|-/\<>*";
proc sort data=education;
   by region;
run;
proc plot data=education nomiss;
    by region;
    plot expenditures*dropoutrate='*' $ state / href=28.6
         vaxis=by 500 vspace=5
         haxis=by 5 hspace=12;
    title 'Plot of Dropout Rate and Expenditure Per Pupil';
run;

Program Description

Set the FORMCHAR option.Setting FORMCHAR to this exact string renders better HTML output when it is viewed outside of the SAS environment where SAS Monospace fonts are not available.
options formchar="|----|+|---+=|-/\<>*";
Sort the EDUCATION data set. PROC SORT sorts EDUCATION by Region so that Region can be used as the BY variable in PROC PLOT.
proc sort data=education;
   by region;
run;
Exclude data points with missing values. NOMISS excludes observations that have a missing value for either of the axis variables.
proc plot data=education nomiss;
Create a separate plot for each BY group. The BY statement creates a separate plot for each value of Region.
    by region;
Create the plot with a reference line and a label for each data point. The plot request plots Expenditures on the vertical axis, plots DropoutRate on the horizontal axis, and specifies an asterisk as the plotting symbol. The label variable specification ($ state) in the PLOT statement labels each point on the plot with the name of the corresponding state. HREF= draws a reference line extending from 28.6 on the horizontal axis. The reference line represents the national average. VAXIS and HAXIS are used to set the tick marks along the vertical and horizontal axes.
    plot expenditures*dropoutrate='*' $ state / href=28.6
         vaxis=by 500 vspace=5
         haxis=by 5 hspace=12;
Specify the title.
    title 'Plot of Dropout Rate and Expenditure Per Pupil';
run;

Output

PROC PLOT produces a plot for each BY group. Only the plot for the Northeast is shown. Because New York has a missing value for Expenditures, the observation is excluded and PROC PLOT does not use the value 35 for DropoutRate to calculate the horizontal axis. Compare the horizontal axis in this output with the horizontal axis in the plot for Northeast in Adding Labels to a Plot.
Plot with Missing Values Excluded
Plot of Dropout Rate and Expenditure Per Pupil, Region=NE