Access SAS

Please read the note on how to access SAS.

Randomization

*Randomization;
data design1;
input treatment @@;
randomv=ranuni(1234);
lines;
1 1 1 1 2 2 2 2 3 3 3 3 3
;
proc print;
proc sort data=design1;
by randomv;
proc print;
run;

Percentiles and Critical Values

* Program to calcualte percentiles of chi-square distribution;
data chisq;
input prob df;
percentile=cinv(prob, df);
lines;
0.05 9
0.95 9
;
proc print data=chisq;
run;

data t;
input prob df;
percentile=tinv(prob, df);
lines;
0.05 9
0.95 9
;
proc print data=t;
run;

data f;
input prob df1 df2;
percentile=finv(prob, df1,df2);
lines;
0.05 2 9
0.95 2 9
;
proc print data=f;
run;

An Example of Analysis Using SAS

The Prius Experiment

In an experiment to study the effects of drivers on the mpg of Toyota Prius, 12 new Prius were randomly assigned to three drivers so that each driver drove four cars and obtained the mpgs. This is a completely randomized design. The data are given below.

  1. The SAS program to get the sample means and sample standard deviations:
data prius;
input driver mpg;
lines;
1 50.33
1 46.83
1 51.57
1 45.33
2 48.11
2 50.14
2 43.22
2 47.26
3 49.08
3 48.89
3 49.96
3 49.70
;
run;
proc print data=prius;
run;

proc means data=prius;
by driver;
run;

proc glm data=prius;
class driver;
model mpg=driver/solution;
lsmeans driver;
means driver;
run;
  1. Find an estimate of the variance \(\sigma^2\).

The estimate is given by the MSE:

\[\begin{eqnarray} M S E &&=\frac{1}{n-v} \sum_{i=1}^3\left(r_i-1\right) s_i^2\\ &&=\frac{1}{12-3}(3 *2.92^2+3 *2.90^2+3 * 0.51^2) \\ &&=5.75. \end{eqnarray}\]
  1. Find the 95% confidence upper limit for \(\sigma^2\).

    First we need to find the \(5^{\text {th }}\) percentile for the \(\chi^2\)-distribution with \(n-v=9\) degrees of freedom, which equals \(\chi_{9,0.95}^2=3.325\). The \(95 \%\) confidence upper limit is given by \(\frac{S S E}{\chi_{9,0.95}^2}=\frac{9 * 5.75}{3.325}=15.55\).

One-Way ANOVA

The ANOVA for the Prius experiment can be carried out in SAS as follows.

proc glm data=prius;
class driver;
 model mpg=driver/solution;
 lsmeans driver;
 means driver;
 run;

The option solution will produce more output information such as the sample means and sample standard deviations.

Partial output: