Example 4. Creating and Modifying Box Plots


Example 4. Creating and Modifying Box Plots

Features:

SYMBOL statement options:

  • BWIDTH=

  • CO=

  • CV=

  • HEIGHT=

  • INTERPOL=

  • VALUE=

Sample library member: GSYCMBP1

click to expand

This example shows how to create box plots and how to specify SYMBOL definitions so data outside the box-plot range can be represented with data points. It also shows how to change a box plot s percentile range to see if the new range encompasses the data.

The first plot in the example uses a SYMBOL definition with INTERPOL=BOXT20 to specify a box plot with whisker tops at the 80th percentile and whisker bottoms at the 20th percentile. Data points that are outside this percentile range are represented with squares.

As illustrated in the following output, the example then changes the SYMBOL definition to INTERPOL=BOXT10, which expands the whisker range to the 90th percentile for tops and the 10th percentile for bottoms. There are no data points outside the new percentile range.

click to expand

Set the graphics environment.

 goptions reset=global gunit=pct border cback=white           colors=(black blue green red)           ftitle=swissb ftext=swiss htitle=6           htext=4; 

Create the data set. GRADES contains codes to identify each class section, and the grades scored by students in each section.

 data grades;     input section $ grade @@;     datalines;  A 74 A 89 A 91 A 76 A 87 A 93 A 93 A 96 A 55 B 72 B 72 B 84 B 81 B 97 B 78 B 88 B 90 B 74  C 62 C 74 C 71 C 87 C 68 C 78 C 80 C 85 C 82  ; 

Define title and footnote.

 title1 'Comparison of Grades by Section';  footnote1 j=r h=3 'GSYCMBP1(a) '; 

Define symbol characteristics. INTERPOL=BOXT20 specifies a box plot with tops and bottoms on its whiskers, and the high and low bounds at the 80th and 20th percentiles. CO= colors the boxes and whiskers. BWIDTH= affects the width of the boxes. VALUE= specifies the plot symbol that marks the data points outside the range of the box plot. CV= colors the plot symbols. HEIGHT= specifies a symbol size .

 symbol interpol=boxt20         co=blue         bwidth=6         value=square         cv=red         height=4; 

Define axis characteristics.

 axis1 label=none        value=(t=1 'Monday' j=c 'section'               t=2 'Wednesday' j=c 'section'               t=3 'Friday' j=c 'section')        offset=(5,5)        length=50; 

Generate the first plot.

 proc gplot data=grades;     plot grade*section / haxis=axis1                          vaxis=50 to 100 by 10;  run; 

Change the footnote.

 footnote j=r h=3 'GSYCMBP1(b) '; 

Change symbol characteristics. INTERPOL=BOXT10 changes the high and low bounds to the 90th percentile at the top and the 10th percentile on the bottom. All other symbol characteristics remain unchanged.

 symbol interpol=boxt10 width=2; 

Generate the second plot.

 plot grade*section / haxis=axis1                          vaxis=50 to 100 by 10;  run;  quit; 



SAS.GRAPH 9.1 Reference, Volumes I and II
SAS.GRAPH 9.1 Reference, Volumes I and II
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 342

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