
SUMMARY OF descriptive statistics commands, continued
=====================================================

(9/17/08)

[Let's start by checking that the algorithm for quantiles is
as advertized. We create a dataset consistint of 10 
observations each at values 1,...,10. Then we generate some
quantiles.]

data temp (keep = value);
  do i=1 to 10;
        do j=1 to 10;
            value = i; output;
        end;
  end; run;

  options nocenter linesize = 90;
  proc means data=temp median q1 q3 p75 p90 p99 maxdex=3;
     var value; run;

The MEANS Procedure
                               Analysis Variable : value

                      Lower          Upper
      Median       Quartile       Quartile      75th Pctl      90th Pctl      99th Pctl
---------------------------------------------------------------------------------------
       5.500          3.000          8.000          8.000          9.500         10.000
---------------------------------------------------------------------------------------

[This confirms that when quantiles fall in intervals, the midpoint
value is reported. Note that we cannot get qunatiles other than a few
standard ones within PROC MEANS.]


libname mydir "."; 
proc univariate data=mydir.polynesT plot;
   var LatitS;
   histogram latitS;
run;

   Stem Leaf                         #  Boxplot
      4 3                            1     0
      3 8                            1     0
      3
      2 578                          3     |
      2 00001122233334              14     |
      1 556666666677888888889999    24  +-----+
      1 00012233                     8  |  +  |
      0 5666788899999               13  +-----+
      0 3                            1     |
     -0                                    |
     -0 9                            1     |
     -1
     -1 99                           2     0
     -2 332221111000                12     0
        ----+----+----+----+----
    Multiply Stem.Leaf by 10**+1


proc gchart data=mydir.polynesT;
    vbar LatitS; run;

[Nice output with red filled-in bars (the default.)
The straggling observations at the ends were the same ones filled in
as "outliers" in boxplot (>= 1.5 InterQuartile ranges above Q3 or
below Q1.) Stars would have been plotted if any points were more than
3 IQrange's out.]

proc univariate data=mydir.polynesT;
   var LatitS; 
   Histogram LatitS / NORMAL; 
   QQPLOT LatitS; 
   PROBPLOT LatitS; run; 

[First is histogram with normal density overplotted.
 Second and third statements plot exactly the same points, the first
 one labelling the x-axis linearly according to `corresponding' normal
 quantiles and the second with those same quantiles labelled by 
 cumulative probabilities in place of normal deviates.]

[Now let's get a plot of empirical distribution function.]


proc freq data=mydir.polynesT ;
   tables LatitS / out = freqLat ;
run;

[Output file has columns Obs, LatitS, and COUNT.]

data freqLat;
  set freqLat (drop=PERCENT) ;
  cumcount + count;
  frac = cumcount/80;
proc print; run;
Obs    LatitS    COUNT    cumcount     frac

  1    -23.30      1          1       0.0125
  2    -23.00      1          2       0.0250
  3    -22.10      2          4       0.0500
  4    -21.50      1          5       0.0625
  5    -21.30      2          7       0.0875
  6    -21.10      2          9       0.1125
  7    -20.50      1         10       0.1250
  8    -20.40      2         12       0.1500
  9    -19.30      2         14       0.1750
 10     -9.30      1         15       0.1875
 11      3.00      1         16       0.2000
 12      5.00      1         17       0.2125
 13      6.12      1         18       0.2250
...

  GOPTIONS HSIZE=5 VSIZE=5; 
  proc gplot data=freqLat;
      plot LatitS*frac; run; 

* Note syntax is plot y*x   ;

[This gives same plot as the probplot but with frequencies stretched
out linearly ...].

[By printing to Postscript file, save  EDF.ps   . ]


goptions reset=ALL;

proc gchart data=mydir.polynesT; 
  title " Histogram with  9  bars";
  VBAR LatitS / Midpoints = -35 to 55 by 10;
run; 

goptions reset=ALL;
goptions hsize=5 vsize=5; 
  proc gchart data=mydir.polynesT;
     title " Histogram with  5  bars";
     VBAR LatitS / Midpoints = -25 to 45 by 15;
   run;

