SAS(Statistical Analysis System)

EXAMPLE SAS FILES for

Exercise 3, page 359

Case 1: Data within SAS FILE

DATA one;

INPUT temp sugar;

CARDS;

1.0 8.1

1.1 7.8

.

.

.

2.0 10.5

;

PROC REG DATA=one;

Model sugar=temp;

Title 'Example 3, page 359';

RUN;

Brief Discussion of Components of the SAS File:

DATA Step

DATA STATEMENT - the first DATA statement names the data set

whose variables are defined in the INPUT statement

-- in the above, we create data set 'one'

INPUT STATEMENT - 2 forms

1. Freefield - can be used when data values are separated by 1

or more blanks

INPUT NAME $ AGE SEX $ SCORE;

($ indicates character variable)

2. Formatted - data occur in fixed columns

INPUT NAME $ 1-20 AGE 22-24 SEX $ 26 SCORE 28-30;

PROGRAM STATEMENTS (optional and not used in the above example

- could have been used to modify data

1. calculate new variables

2. modify existing variables

3. select a subset of data set upon which the statistical

analysis will be performed.

CARDS STATEMENT

- used to indicate that the next records in the file

contain the actual data and the semicolon after the data

indicates the end of the data itself

SPECIFYING THE ANALYSIS -- PROC STATEMENTS

GENERAL FORM

PROC xxxxx; - implies procedure is to be run on most recently

created data set

PROC xxxxx DATA = data set name;

Note: I did not have to specify DATA=one in the above example

Examples PROCs:

PROC REG - regression analysis

PROC ANOVA - analysis of variance

PROC GLM - general linear model

PROC MEANS - basic statistics, t-test for H0: m=0

PROC PLOT - plotting

PROC TTEST - t-tests

PROC UNIVARIATE - descriptive stats, box-plots, stem & leaf

General Cautions and comments:

1. Each statement should be concluded with a semicolon

2. SAS names can be from 1 to 8 characters in length and must

begin with a letter or an underscore

Case 2: Data in an External File

FILENAME f1 'ex3p359.data';

DATA one;

INFILE f1;

INPUT temp sugar;

PROC REG DATA=one;

MODEL sugar=temp;

Title 'Example 3, page 359';

RUN;

Discussion:

The data resides in external file "ex3p359.data" and is given the name f1 for this SAS run. However, in the DATA step, we give the data set to be analyzed the name "one". Additional data sets can be created within the SAS file.

Running the SAS job on TITAN

Files such as "internal.sas", "external.sas", and "ex3p359.data" are files that are usually created on your UNIX machine using an editor such as VI or PICO. For this particular example, a UNIX editor was used to create the file "internal.sas". To then run this SAS job on a UNIX machine that has access to SAS, type the command

sas internal

Two files will be created:

(1) internal.log -- which gives information on the run (time,

etc. along with any error messages.

(2) internal.lst -- the output from the SAS run. (errors may

cause this file to not be created.)

EXAMPLE FILES ON INTERNET

The SAS files and the data for Example 3, p.359 are avaiable for downloading. These files are as follows:

1. internal.sas - the SAS file in (1) above with data

contained within the SAS file

2. external.sas - the SAS file in (2) above for the case

in which data are in an external file

3. ex3p359.data - the external data file containing the

data for Example3, p.359

EXAMPLE 3, page 359 SAS Output

Example 3, page 359

The REG Procedure

Model: MODEL1

Dependent Variable: sugar

Analysis of Variance

Sum of Mean

Source DF Squares Square F Value Pr > F

Model 1 3.60009 3.60009 9.00 0.0150

Error 9 3.60173 0.40019

Corrected Total 10 7.20182

Root MSE 0.63261 R-Square 0.4999

Dependent Mean 9.12727 Adj R-Sq 0.4443

Coeff Var 6.93096

Parameter Estimates

Parameter Standard

Variable DF Estimate Error t Value Pr > |t|

Intercept 1 6.41364 0.92464 6.94 <.0001

temp 1 1.80909 0.60317 3.00 0.0150

EXERCISE 3 - page 408

filename cook 'ex3p408.data';

Data one;

infile cook;

input y x1 x2;

proc REG;

model y=x1 x2;

title 'Exercise 3, page 408';

run;

Exercise 3, page 408

Model: MODEL1

Dependent Variable: Y

Analysis of Variance

Sum of Mean

Source DF Squares Square F Value Prob>F

Model 2 10953.20257 5476.60129 12688.741 0.0001

Error 7 3.02128 0.43161

C Total 9 10956.22385

Root MSE 0.65697 R-square 0.9997

Dep Mean 48.91500 Adj R-sq 0.9996

C.V. 1.34309

Parameter Estimates

Parameter Standard T for H0:

Variable DF Estimate Error Parameter=0 Prob > |T|

INTERCEP 1 0.579988 0.60685346 0.956 0.3710

X1 1 2.712238 0.20208644 13.421 0.0001

X2 1 2.049707 0.04808181 42.630 0.0001

DATA IN TABLE 12.4 - page 433

STEPWISE RESULTS FROM SAS

Stepwise Procedure for Dependent Variable Y

Step 1 Variable X1 Entered R-square = 0.89698302 C(p) = 39.63635101

DF Sum of Squares Mean Square F Prob>F

Regression 1 288.14682495 288.14682495 60.95 0.0001

Error 7 33.09317505 4.72759644

Total 8 321.24000000

Parameter Standard Type II

Variable Estimate Error Sum of Squares F Prob>F

INTERCEP 19.01108007 5.42271930 58.10583282 12.29 0.0099

X1 0.51797020 0.06634651 288.14682495 60.95 0.0001

Note: These F values

are the squares of the

usual t-values in SAS

See 3rd page.

Bounds on condition number: 1, 1

------

Step 2 Variable X3 Entered R-square = 0.98821914 C(p) = 2.10454082

DF Sum of Squares Mean Square F Prob>F

Regression 2 317.45551809 158.72775905 251.65 0.0001

Error 6 3.78448191 0.63074698

Total 8 321.24000000

Parameter Standard Type II

Variable Estimate Error Sum of Squares F Prob>F

INTERCEP 20.10845029 1.98725776 64.58088391 102.39 0.0001

X1 0.41362967 0.02866328 131.34899803 208.24 0.0001

X3 2.02533400 0.29711598 29.30869314 46.47 0.0005

Bounds on condition number: 1.398946, 5.595783

------

All variables left in the model are significant at the 0.1500 level.

No other variable met the 0.1500 significance level for entry into the model.

Summary of Stepwise Procedure for Dependent Variable Y

Variable Number Partial Model

Step Entered Removed In R**2 R**2 C(p) F Prob>F

1 X1 1 0.8970 0.8970 39.6364 60.9500 0.0001

2 X3 2 0.0912 0.9882 2.1045 46.4666 0.0005

This is the end of the SAS STEPWISE output.

NOTICE: SAS picked 2 independent variables and then stopped. The next pages show SAS output from standard PROC REG. Each set of output on the following pages is from a separate running of PROC REG.

SAS file that produced the Stepwise output shown above.

filename infant 'tablep433.data';

Data one;

infile infant;

input y x1 x2 x3 x4;

proc reg;

model y=x1 x2 x3 x4/selection=stepwise;

run;

Standard SAS PROC REG Printout for 3 Features

- to show why STEPWISE Procedure stopped with 2 features

X1, X3, and X4

Dependent Variable: Y

Analysis of Variance

Sum of Mean

Source DF Squares Square F Value Prob>F

Model 3 317.64101 105.88034 147.097 0.0001

Error 5 3.59899 0.71980

C Total 8 321.24000

Root MSE 0.84841 R-square 0.9888

Dep Mean 60.96667 Adj R-sq 0.9821

C.V. 1.39160

Parameter Estimates

Parameter Standard T for H0:

Variable DF Estimate Error Parameter=0 Prob > |T|

INTERCEP 1 21.873528 4.07388552 5.369 0.0030

X1 1 0.412771 0.03066663 13.460 0.0001

X3 1 2.202668 0.47198905 4.667 0.0055

X4 1 -0.078945 0.15551477 -0.508 0.6333

Note: p-value for X4

is too large.

X1, X3, and X2

Dependent Variable: Y

Analysis of Variance

Sum of Mean

Source DF Squares Square F Value Prob>F

Model 3 318.25027 106.08342 177.413 0.0001

Error 5 2.98973 0.59795

C Total 8 321.24000

Root MSE 0.77327 R-square 0.9907

Dep Mean 60.96667 Adj R-sq 0.9851

C.V. 1.26835

Parameter Estimates

Parameter Standard T for H0:

Variable DF Estimate Error Parameter=0 Prob > |T|

INTERCEP 1 5.629827 12.70680159 0.443 0.6762

X1 1 0.080984 0.28988008 0.279 0.7911

X3 1 3.069358 0.95066097 3.229 0.0232

X2 1 0.771498 0.66918975 1.153 0.3011

Note:X2 really “messes up”

the p-values, and the p-value

for X2 is too large

Showing Standard SAS PROC Reg Output for X1 and for X1 & X3

- for comparison with the the STEPWISE Output

X1

Dependent Variable: Y

Analysis of Variance

Sum of Mean

Source DF Squares Square F Value Prob>F

Model 1 288.14682 288.14682 60.950 0.0001

Error 7 33.09318 4.72760

C Total 8 321.24000

Root MSE 2.17430 R-square 0.8970

Dep Mean 60.96667 Adj R-sq 0.8823

C.V. 3.56638

Parameter Estimates

Parameter Standard T for H0:

Variable DF Estimate Error Parameter=0 Prob > |T|

INTERCEP 1 19.011080 5.42271930 3.506 0.0099

X1 1 0.517970 0.06634651 7.807 0.0001

X1 and X3

Dependent Variable: Y

Analysis of Variance

Sum of Mean

Source DF Squares Square F Value Prob>F

Model 2 317.45552 158.72776 251.650 0.0001

Error 6 3.78448 0.63075

C Total 8 321.24000

Root MSE 0.79420 R-square 0.9882

Dep Mean 60.96667 Adj R-sq 0.9843

C.V. 1.30267

Parameter Estimates

Parameter Standard T for H0:

Variable DF Estimate Error Parameter=0 Prob > |T|

INTERCEP 1 20.108450 1.98725776 10.119 0.0001

X1 1 0.413630 0.02866328 14.431 0.0001

X3 1 2.025334 0.29711598 6.817 0.0005

Standard SAS PROC REG Output for all 4 Independent Variables

X1, X2, X3, and X4

Dependent Variable: Y

Analysis of Variance

Sum of Mean

Source DF Squares Square F Value Prob>F

Model 4 318.27442 79.56860 107.323 0.0003

Error 4 2.96558 0.74140

C Total 8 321.24000

Root MSE 0.86104 R-square 0.9908

Dep Mean 60.96667 Adj R-sq 0.9815

C.V. 1.41232

Parameter Estimates

Parameter Standard T for H0:

Variable DF Estimate Error Parameter=0 Prob > |T|

INTERCEP 1 7.147532 16.45961128 0.434 0.6865

X1 1 0.100094 0.33970898 0.295 0.7829

X2 1 0.726417 0.78590156 0.924 0.4076

X3 1 3.075837 1.05917874 2.904 0.0439

X4 1 -0.030042 0.16646232 -0.180 0.8656

Note: Even though the overall

p-value is small (.0003),

there is much confusion

concerning the contribution of

the individual X variables

- this is probably due to

multicollinearity

SAS file to run the multiple regression based on X1 and X3 and print 3 residual plots

filename infant 'tablep433.data';

Data one;

infile infant;

input y x1 x2 x3 x4;

proc reg lp;

model y=x1 x3;

plot residual.*x1;

plot residual.*x3;

plot residual.*obs.;

title 'Residual Plots';

run;

SAS Output – Notice that the output on this page is the same as the output previously shown for using X1 and X3.

Residual

Model: MODEL1

Dependent Variable: Y

Analysis of Variance

Sum of Mean

Source DF Squares Square F Value Prob>F

Model 2 317.45552 158.72776 251.650 0.0001

Error 6 3.78448 0.63075

C Total 8 321.24000

Root MSE 0.79420 R-square 0.9882

Dep Mean 60.96667 Adj R-sq 0.9843

C.V. 1.30267

Parameter Estimates

Parameter Standard T for H0:

Variable DF Estimate Error Parameter=0 Prob > |T|

INTERCEP 1 20.108450 1.98725776 10.119 0.0001

X1 1 0.413630 0.02866328 14.431 0.0001

X3 1 2.025334 0.29711598 6.817 0.0005

Residual Plots

------+------+------+------+------+------+------+------+------+------

RESIDUAL | |

| |

0.8 + 1 1 +

| 1 |

| |

| |

| |

0.6 + +

| |

| |

| |

| |

0.4 + 1 +

| |

| |

| |

| |

0.2 + +

| |

| |

| |

R | |

e 0.0 + +

s | |

i | |

d | |

u | |

a -0.2 + 1 +

l | |

| |

| |

| |

-0.4 + +

| 1 |

| |

| |

| |

-0.6 + 1 +

| |

| 1 |

| |

| |

-0.8 + +

| 1 |

| |

| |

| |

-1.0 + +

| |

| |

------+------+------+------+------+------+------+------+------+------

65 70 75 80 85 90 95 100 105

X1

Residual Plots

------+------+------+------+------+------+------+------+------

RESIDUAL | |

| |

0.8 + 1 1 +

| 1 |

| |

| |

| |

0.6 + +

| |

| |

| |

| |

0.4 + 1 +

| |

| |

| |

| |

0.2 + +

| |

| |

| |

R | |

e 0.0 + +

s | |

i | |

d | |

u | |

a -0.2 + 1 +

l | |

| |

| |

| |

-0.4 + +

| 1 |

| |

| |

| |

-0.6 + 1 +

| |

| 1 |

| |

| |

-0.8 + +

| 1 |

| |

| |

| |

-1.0 + +

| |

| |

------+------+------+------+------+------+------+------+------

2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5

X3

Residual Plots

------+------+------+------+------+------+------+------+------+------

RESIDUAL | |

| |

0.8 + 1 1 +

| 1 |

| |

| |

| |

0.6 + +

| |

| |

| |

| |

0.4 + 1 +

| |

| |

| |

| |

0.2 + +

| |

| |

| |

R | |

e 0.0 + +

s | |

i | |

d | |

u | |

a -0.2 + 1 +

l | |

| |

| |

| |

-0.4 + +

| 1 |

| |

| |

| |

-0.6 + 1 +

| |

| 1 |

| |

| |

-0.8 + +

| 1 |

| |

| |

| |

-1.0 + +

| |

| |

------+------+------+------+------+------+------+------+------+------

1 2 3 4 5 6 7 8 9

Observation Number OBS NUM

CAR DATA EXAMPLE

For this analysis, 5 gasoline types (A - E) were to be tested. Twenty cars

were selected for testing and were assigned randomly to the groups (i.e. the

gasoline types). Thus, in the analysis, each gasoline type was tested on

4 cars. A performance-based octane reading was obtained for each car,

and the question is whether the gasolines differ with respect to this octane

reading.

The data set follows:

A 91.7

A 91.2

A 90.9

A 90.6

B 91.7

B 91.9

B 90.9

B 90.9

C 92.4

C 91.2

C 91.6

C 91.0

D 91.8

D 92.2

D 92.0

D 91.4

E 93.1

E 92.9

E 92.4

E 92.4

The SAS file used:

FILENAME f1 'car.data';

Options ls=80;

DATA one;

INFILE f1;

INPUT gas$ octane;

PROC GLM;

CLASS gas;

MODEL octane=gas;

TITLE 'Gasoline Example - Completely Randomized Design';

MEANS gas/duncans;

RUN;

PROC MEANS mean var;

RUN;

PROC MEANS mean var;

class gas;

run;

The SAS Output follows:

Gasoline Example - Completely Randomized Design

General Linear Models Procedure

Dependent Variable: OCTANE

Sum of Mean

Source DF Squares Square F Value Pr > F

Model 4 6.10800000 1.52700000 6.80 0.0025

Error 15 3.37000000 0.22466667

Corrected Total 19 9.47800000

R-Square C.V. Root MSE OCTANE Mean

0.644440 0.516836 0.4739902 91.710000

Source DF Type I SS Mean Square F Value Pr > F

GAS 4 6.10800000 1.52700000 6.80 0.0025

Source DF Type III SS Mean Square F Value Pr > F

GAS 4 6.10800000 1.52700000 6.80 0.0025

Gasoline Example - Completely Randomized Design

General Linear Models Procedure

Duncan's Multiple Range Test for variable: OCTANE

NOTE: This test controls the type I comparisonwise error rate, not

the experimentwise error rate

Alpha= 0.05 df= 15 MSE= 0.224667

Number of Means 2 3 4 5

Critical Range .7144 .7489 .7703 .7849

Means with the same letter are not significantly different.

Duncan Grouping Mean N GAS

A 92.7000 4 E

B 91.8500 4 D

B

B 91.5500 4 C

B

B 91.3500 4 B

B

B 91.1000 4 A

Output from PROC MEANS:

Gasoline Example - Completely Randomized

Analysis Variable : OCTANE

Mean Variance

------

91.7100000 0.4988421

------

Gasoline Example - Completely Randomized Design

Analysis Variable : OCTANE

GAS N Obs Mean Variance

------

A 4 91.1000000 0.2200000

B 4 91.3500000 0.2766667

C 4 91.5500000 0.3833333

D 4 91.8500000 0.1166667

E 4 92.7000000 0.1266667

------

BALLOON DATA

Col. 1-2 - observation number

Col. 3 - color (1=pink, 2=yellow, 3=orange, 4=blue)

Col. 4-7 - inflation time in seconds

1122.4

2324.6

3120.3

4419.8

5324.3

6222.2

7228.5

8225.7

9320.2

10119.6

11228.8

12424.0

13417.1

14419.3

15324.2

16115.8

17218.3

18117.5

19418.7

20322.9

21116.3

22414.0

23416.6

24218.1

25218.9

26416.0

27220.1

28322.5

29316.0

30119.3

31115.9

32320.3

SAS file for running "Balloon Data"

data balloon;

infile 'balloon.data';

input

runcov 1-2

color 3-3

time 4-7

;

proc glm;

classes color;

model time=color;

title 'ANOVA --- Balloon Data';

means color/duncans;

run;

SAS OUTPUT

ANOVA --- Balloon Data

General Linear Models Procedure

Dependent Variable: TIME

Sum of Mean

Source DF Squares Square F Value Pr > F

Model 3 126.15125000 42.05041667 3.85 0.0200

Error 28 305.64750000 10.91598214

Corrected Total 31 431.79875000

R-Square C.V. Root MSE TIME Mean

0.292153 16.31069 3.3039343 20.256250

General Linear Models Procedure

Duncan's Multiple Range Test for variable: TIME

NOTE: This test controls the type I comparisonwise error rate, not

the experimentwise error rate

Alpha= 0.05 df= 28 MSE= 10.91598

Number of Means 2 3 4

Critical Range 3.384 3.556 3.667

Means with the same letter are not significantly different.

Duncan Grouping Mean N COLOR

A 22.575 8 2

A

A 21.875 8 3

B 18.388 8 1

B

B 18.188 8 4

RANDOMIZED COMPLETE BLOCK DESIGN FOR GASOLINE DATA

The first variable (A - E) indicates gas as it did with the Completely

Randomized Design. The second variable (B1 - B4) indicates car. In this

design, there are only 4 cars, and the 5 gas types are tested on each car

as mentioned in lecture.

A B1 91.7

A B2 91.2

A B3 90.9

A B4 90.6

B B1 91.7

B B2 91.9

B B3 90.9

B B4 90.9

C B1 92.4

C B2 91.2

C B3 91.6

C B4 91.0

D B1 91.8

D B2 92.2

D B3 92.0

D B4 91.4

E B1 93.1

E B2 92.9

E B3 92.4

E B4 92.4

SAS file for Randomized Complete Block Design for gas data.

FILENAME f1 'carblk.data';

Options ls=80;

DATA one;

INFILE f1;

INPUT gas$ block$ octane;

PROC ANOVA;

CLASS gas block;

MODEL octane=gas block;

TITLE 'Gasoline Example -Randomized Complete Block Design';

MEANS gas/duncans;

RUN;

PROC MEANS mean var;

class block;

RUN;

PROC MEANS mean var;

class gas;

run;

Gasoline Example -Randomized Complete Block Design

Analysis of Variance Procedure

Class Level Information

Class Levels Values

GAS 5 A B C D E

BLOCK 4 B1 B2 B3 B4

Number of observations in data set = 20

Dependent Variable: OCTANE

Sum of Mean

Source DF Squares Square F Value Pr > F

Model 7 8.30200000 1.18600000 12.10 0.0001

Error 12 1.17600000 0.09800000

Corrected Total 19 9.47800000

R-Square C.V. Root MSE OCTANE Mean

0.875923 0.341347 0.3130495 91.710000

Source DF Anova SS Mean Square F Value Pr > F

GAS 4 6.10800000 1.52700000 15.58 0.0001

BLOCK 3 2.19400000 0.73133333 7.46 0.0044

Duncan's Multiple Range Test for variable: OCTANE

NOTE: This test controls the type I comparisonwise error rate, not

the experimentwise error rate

Alpha= 0.05 df= 12 MSE= 0.098

Number of Means 2 3 4 5

Critical Range .4823 .5048 .5185 .5275

Means with the same letter are not significantly different.

Duncan Grouping Mean N GAS

A 92.7000 4 E

B 91.8500 4 D

B

C B 91.5500 4 C

C B

C B 91.3500 4 B

C

C 91.1000 4 A

Gasoline Example -Randomized Complete Block Design

Analysis Variable : OCTANE

BLOCK N Obs Mean Variance

------

B1 5 92.1400000 0.3730000

B2 5 91.8800000 0.5170000

B3 5 91.5600000 0.4430000

B4 5 91.2600000 0.4880000

------

Gasoline Example -Randomized Complete Block Design

Analysis Variable : OCTANE

GAS N Obs Mean Variance

------

A 4 91.1000000 0.2200000

B 4 91.3500000 0.2766667

C 4 91.5500000 0.3833333

D 4 91.8500000 0.1166667

E 4 92.7000000 0.1266667

------

STIMULUS EXAMPLE: 2-Factor ANOVA

Personal computer presents stimulus, and person responds:

Study of how RESPONSE TIME is effected by a WARNING:

WARNING given prior to stimulus:

- auditory or visual

- 5 sec, 10 sec, or 15 sec before stimulus

TABLE OF RESPONSE TIMES

WARNING TYPE

Auditory / Visual
.204 / .257
5 sec / .170 / .279
.181 / .269
WARNING / .167 / .283
TIME / 10 sec / .182 / .235
.187 / .260
.202 / .256
15 sec / .198 / .281
.236 / .258

STMULUS EXAMPLE (2-Factor ANOVA):

Data:

Factor A: A=auditory warning, V=visual warning

Factor B: Time between warning and stimulus

Variable: Reaction time (I called it "response" in SAS)

A 5 .204

A 5 .170

A 5 .181

A 10 .167

A 10 .182

A 10 .187

A 15 .202

A 15 .198

A 15 .236

V 5 .257

V 5 .279

V 5 .269

V 10 .283

V 10 .235

V 10 .260

V 15 .256

V 15 .281

V 15 .258

SAS File:

FILENAME f1 'stimulus.data';

Options ls=80;

DATA one;

INFILE f1;

INPUT type$ time response;

PROC GLM;

class type time;

MODEL response=type time type*time;

Title 'Stimulus Example -- 2-way ANOVA';

MEANS type time/Duncan;

RUN;

PROC MEANS mean var;

class type time;

var response;

run;

Stimulus Example -- 2-way ANOVA

General Linear Models Procedure

Class Level Information

Class Levels Values

TYPE 2 A V

TIME 3 5 10 15

Number of observations in data set = 18

Dependent Variable: RESPONSE

Sum of Mean

Source DF Squares Square F Value Pr > F

Model 5 0.02554894 0.00510979 17.66 0.0001

Error 12 0.00347200 0.00028933

Corrected Total 17 0.02902094

R-Square C.V. Root MSE RESPONSE Mean

0.880362 7.458622 0.0170098 0.2280556

Source DF Type I SS Mean Square F Value Pr > F

TYPE 1 0.02354450 0.02354450 81.38 0.0001

TIME 2 0.00115811 0.00057906 2.00 0.1778

TYPE*TIME 2 0.00084633 0.00042317 1.46 0.2701

Source DF Type III SS Mean Square F Value Pr > F

TYPE 1 0.02354450 0.02354450 81.38 0.0001

TIME 2 0.00115811 0.00057906 2.00 0.1778

TYPE*TIME 2 0.00084633 0.00042317 1.46 0.2701

Stimulus Example -- 2-way ANOVA

General Linear Models Procedure

Duncan's Multiple Range Test for variable: RESPONSE

NOTE: This test controls the type I comparisonwise error rate, not

the experimentwise error rate

Alpha= 0.05 df= 12 MSE= 0.000289

Number of Means 2

Critical Range .01747

Means with the same letter are not significantly different.

Duncan Grouping Mean N TYPE

A 0.264222 9 V

B 0.191889 9 A

Duncan's Multiple Range Test for variable: RESPONSE

Alpha= 0.05 df= 12 MSE= 0.000289

Number of Means 2 3

Critical Range .02140 .02240

Means with the same letter are not significantly different.

Duncan Grouping Mean N TIME

A 0.238500 6 15

A

A 0.226667 6 5

A

A 0.219000 6 10

Stimulus Example -- 2-way ANOVA

Analysis Variable : RESPONSE

The MEANS Procedure

Analysis Variable : response

N

type time Obs Mean Variance

------

A 5 3 0.1850000 0.000301000

10 3 0.1786667 0.000108333

15 3 0.2120000 0.000436000

V 5 3 0.2683333 0.000121333

10 3 0.2593333 0.000576333

15 3 0.2650000 0.000193000

------

PILOT PLANT DATA

Variable = Chemical Yield

Factors:A – Temperature (160, 180)

B – Catalyst (C1 , C2)

160 C1 59

160 C1 61

160 C1 50

160 C1 58

180 C1 74

180 C1 70

180 C1 69

180 C1 67

160 C2 50

160 C2 54

160 C2 46

160 C2 44

180 C2 81

180 C2 85

180 C2 79

180 C2 81

SAS File for 2-Factor Factorial Analysis of

Pilot-Plant Data

FILENAME f1 'pilot.data';

Options ls=80;

DATA one;

INFILE f1;

INPUT temp catalyst$ yield;

PROC GLM;

class temp catalyst;

MODEL yield=temp catalyst temp*catalyst;

Title 'Pilot Plant Example -- 2-way ANOVA';

MEANS temp catalyst/Duncan;

RUN;

PROC MEANS;

class temp catalyst;

var yield;

run;

SAS Output

Pilot Plant Example -- 2-way ANOVA

General Linear Models Procedure

Dependent Variable: YIELD

Sum of Mean

Source DF Squares Square F Value Pr > F

Model 3 2525.0000000 841.6666667 58.05 0.0001

Error 12 174.0000000 14.5000000

Corrected Total 15 2699.0000000

R-Square C.V. Root MSE YIELD Mean

0.935532 5.926672 3.8078866 64.250000

Source DF Type I SS Mean Square F Value Pr > F

TEMP 1 2116.0000000 2116.0000000 145.93 0.0001

CATALYST 1 9.0000000 9.0000000 0.62 0.4461

TEMP*CATALYST 1 400.0000000 400.0000000 27.59 0.0002

Duncan's Multiple Range Test for variable: YIELD

NOTE: This test controls the type I comparisonwise error rate, not

the experimentwise error rate

Alpha= 0.05 df= 12 MSE= 14.5

Number of Means 2

Critical Range 4.148

Means with the same letter are not significantly different.

Duncan Grouping Mean N TEMP

A 75.750 8 180

B 52.750 8 160

Duncan's Multiple Range Test for variable: YIELD

NOTE: This test controls the type I comparisonwise error rate, not

the experimentwise error rate

Alpha= 0.05 df= 12 MSE= 14.5

Number of Means 2

Critical Range 4.148

Means with the same letter are not significantly different.

Duncan Grouping Mean N CATALYST

A 65.000 8 C2

A

A 63.500 8 C1

PROC PRINT Output:

Pilot Plant Example -- 2-way

Analysis Variable : YIELD

TEMP CATALYST N Obs N Mean Std Dev Minimum

------

160 C1 4 4 57.0000000 4.8304589 50.0000000

C2 4 4 48.5000000 4.4347116 44.0000000

180 C1 4 4 70.0000000 2.9439203 67.0000000

C2 4 4 81.5000000 2.5166115 79.0000000

------

TEMP CATALYST N Obs Maximum

------

160 C1 4 61.0000000

C2 4 54.0000000

180 C1 4 74.0000000

C2 4 85.0000000

------

POPCORN EXAMPLE – 3-FACTOR FACTORIAL MODEL

1 500 5 73.8

1 500 5 65.5

1 500 4.5 70.3

1 500 4.5 91.0

1 500 4 72.7

1 500 4 81.9

1 600 5 70.8

1 600 5 75.3

1 600 4.5 78.7

1 600 4.5 88.7

1 600 4 74.1

1 600 4 72.1

2 500 5 73.7

2 500 5 65.8

2 500 4.5 93.4

2 500 4.5 76.3

2 500 4 45.3

2 500 4 47.6

2 600 5 79.3

2 600 5 86.5

2 600 4.5 92.2

2 600 4.5 84.7

2 600 4 66.3

2 600 4 45.7

3 500 5 62.5

3 500 5 65.0

3 500 4.5 50.1

3 500 4.5 81.5

3 500 4 51.4

3 500 4 67.7

3 600 5 82.1

3 600 5 74.5

3 600 4.5 71.5

3 600 4.5 80.0

3 600 4 64.0

3 600 4 77.0

FILENAME f1 'popcorn.data';

Options ls=80;

DATA one;

INFILE f1;

INPUT brand power time percent;

PROC GLM;

class brand power time;

MODEL percent=brand power time brand*power brand*time power*time brand*power*time;

Title 'Popcorn Example -- 3-Factor ANOVA';

MEANS brand power time/Duncan;

RUN;

PROC MEANS;

class brand power time;

var percent;

run;

Popcorn Example -- 3-Factor ANOVA

General Linear Models Procedure

Class Level Information

Class Levels Values

BRAND 3 1 2 3

POWER 2 500 600

TIME 3 4 5 4.5

Number of observations in data set = 36

Popcorn Example -- 3-Factor ANOVA

General Linear Models Procedure

Dependent Variable: PERCENT

Sum of Mean

Source DF Squares Square F Value Pr > F

Model 17 4065.7288889 239.1605229 2.73 0.0206

Error 18 1577.8700000 87.6594444

Corrected Total 35 5643.5988889

R-Square C.V. Root MSE PERCENT Mean

0.720414 12.96867 9.3626623 72.194444

Source DF Type I SS Mean Square F Value Pr > F

BRAND 2 331.1005556 165.5502778 1.89 0.1801

POWER 1 455.1111111 455.1111111 5.19 0.0351

TIME 2 1554.5755556 777.2877778 8.87 0.0021

BRAND*POWER 2 196.0405556 98.0202778 1.12 0.3485

BRAND*TIME 4 1433.8577778 358.4644444 4.09 0.0157

POWER*TIME 2 47.7088889 23.8544444 0.27 0.7648

BRAND*POWER*TIME 4 47.3344444 11.8336111 0.13 0.9673

Popcorn Example -- 3-Factor ANOVA

General Linear Models Procedure

Duncan's Multiple Range Test for variable: PERCENT