When ODS Graphics is disabled, the PLOT option in the PROC UNIVARIATE statement requests several basic plots for display in line printer output. For more information about plots created by the PLOT option, see the section Creating Line Printer Plots. This example illustrates the use of the PLOT option as well as BY processing in PROC UNIVARIATE.
A researcher is analyzing a data set consisting of air pollution data from three different measurement sites. The data set
AirPoll
, created by the following statements, contains the variables Site
and Ozone
, which are the site number and ozone level, respectively.
data AirPoll (keep = Site Ozone); label Site = 'Site Number' Ozone = 'Ozone level (in ppb)'; do i = 1 to 3; input Site @@; do j = 1 to 15; input Ozone @@; output; end; end; datalines; 102 4 6 3 4 7 8 2 3 4 1 3 8 9 5 6 134 5 3 6 2 1 2 4 3 2 4 6 4 6 3 1 137 8 9 7 8 6 7 6 7 9 8 9 8 7 8 5 ;
The following statements produce stem-and-leaf plots, box plots, and normal probability plots for each site in the AirPoll
data set:
ods graphics off; ods select Plots SSPlots; proc univariate data=AirPoll plot; by Site; var Ozone; run;
The PLOT option produces a stem-and-leaf plot, a box plot, and a normal probability plot for the Ozone
variable at each site. Because the BY statement is used, a side-by-side box plot is also created to compare the ozone levels
across sites. Note that AirPoll
is sorted by Site
; in general, the data set should be sorted by the BY variable by using the SORT procedure. The ODS SELECT statement restricts
the output to the “Plots” and “SSPlots” tables; see the section ODS Table Names. Optionally, you can specify the PLOTSIZE= option to control the approximate number of rows (between 8 and the page size) that the plots occupy.
Output 4.5.1 through Output 4.5.3 show the plots produced for each BY group. Output 4.5.4 shows the side-by-side box plot for comparing Ozone
values across sites.
Output 4.5.1: Ozone Plots for BY Group Site = 102
Analysis of Score Changes |
Stem Leaf # Boxplot 9 0 1 | 8 00 2 | 7 0 1 +-----+ 6 00 2 | | 5 0 1 | | 4 000 3 *--+--* 3 000 3 +-----+ 2 0 1 | 1 0 1 | ----+----+----+----+ Normal Probability Plot 9.5+ *++++ | * * ++++ | * +++++ | * *+++ 5.5+ +*++ | **+* | * *+*+ | *++++ 1.5+ *++++ +----+----+----+----+----+----+----+----+----+----+ -2 -1 0 +1 +2 |
Output 4.5.2: Ozone Plots for BY Group Site = 134
Analysis of Score Changes |
Stem Leaf # Boxplot 6 000 3 | 5 0 1 +-----+ 4 000 3 | | 3 000 3 *--+--* 2 000 3 +-----+ 1 00 2 | ----+----+----+----+ Normal Probability Plot 6.5+ * * ++*+++ | * ++++++ | **+*+++ | **+*+++ | *+*+*++ 1.5+ * ++*+++ +----+----+----+----+----+----+----+----+----+----+ -2 -1 0 +1 +2 |
Output 4.5.3: Ozone Plots for BY Group Site = 137
Analysis of Score Changes |
Stem Leaf # Boxplot 9 000 3 | 8 00000 5 +-----+ 7 0000 4 +--+--+ 6 00 2 | 5 0 1 0 ----+----+----+----+ Normal Probability Plot 9.5+ * *++++*++++ | * ** *+*+++++ 7.5+ * * **++++++ | *++*+++++ 5.5+ +++*++++ +----+----+----+----+----+----+----+----+----+----+ -2 -1 0 +1 +2 |
Output 4.5.4: Ozone Side-by-Side Boxplot for All BY Groups
Analysis of Score Changes |
| 10 + | | | | | | | 8 + | *-----* | | | + | | +-----+ +-----+ | | | | 6 + | | | | | | | | | | + | +-----+ 0 | | | | | 4 + *-----* | | | | | | + | | +-----+ *-----* | | | | 2 + | +-----+ | | | | | | | 0 + ------------+-----------+-----------+----------- Site 102 134 137 |
Note that you can use the PROBPLOT statement with the NORMAL option to produce high-resolution normal probability plots; see the section Modeling a Data Distribution.
Note that you can use the BOXPLOT procedure to produce box plots that use high-resolution graphics. See Chapter 26: The BOXPLOT Procedure in SAS/STAT 12.1 User's Guide,.
A sample program for this example, uniex04.sas, is available in the SAS Sample Library for Base SAS software.