Box-whisker plot with uneven distributed values in the axis

 

Author: Xuanqian Xie 

In general, we can use “order” option in axis statement to define the not uniform distributed values. “The specified values are spaced evenly along the axis even if the values are not distributed uniformly.” See the link: http://support.sas.com/documentation/cdl/en/graphref/63022/HTML/default/viewer.htm#axischap.htm

But, for the “proc boxplot” procedure, it has additional requirement.”The values must be listed in increasing order, must be evenly spaced, and must span the range of values displayed in the plot.” See the link:

http://support.sas.com/documentation/cdl/en/statug/63347/HTML/default/viewer.htm#statug_boxplot_sect012.htm

So, we can conclude that we cannot define the axis with different value increased by proc boxplot.

But, we can consider using proc gplot for it. See the example code. The graph can be nice with large sample size.

This graph was prepared for one of my friend.

 

 

libname aa "G:\2012\sas_r_code";

proc print data=aa.aa;

run;

 

                                Obs     alloc            y

 

                                      1    Control       24.67

                                      2     Study       -12.44

                                      3    Control      712.58

                                      4     Study     -4647.28

                                      5     Study     -6934.04

                                      6    Control       -5.26

                                      7    Control      -41.33

                                      8    Control      627.33

                                      9    Control     -568.22

                                     10    Control     -160.40

                                     11     Study       -88.51

                                     12    Control        6.14

                                     13     Study       -26.86

                                     14     Study       -76.00

                                     15    Control     -169.75

 

 

data aa;

set aa.aa;

i=_n_;

u = round( 1000*rand("Uniform"));

do m=1 to 10;

seed=u;

T1=round(3000*rand("Uniform"))      ;

y1 =y +T1 ;

output;

end;

 

run;

 

 

goptions reset=all;

symbol value = dot

height = 0.4

interpol = boxtf

width = 3

bwidth = 5

co = BL

cv = TAN ;

axis1 order = (-7000, -5000, -3000, -1000, -500, 0, 200, 400, 600, 800, 1000, 3000) offset = (5, 5)      ;

axis2 order = ( "Control"   " Study")    offset = (30, 30);

 

proc gplot data = aa uniform ;

plot y1*alloc / vaxis = axis1       haxis = axis2

hminor = 0

skipmiss ;

run;

quit;

Prev product:No prev product
Next productPopulation EVPI