Programming the statistical procedures from SAS

Help with SAS Anova codes

Accepted Solution Solved
Reply
Contributor
Posts: 46
Accepted Solution

Help with SAS Anova codes

I am trying to figure out what I am doing wrong with this ANOVA code. Help please.

question

 

A researcher was interested in the influence of test administration practices (in-class testing vs. take-home testing) on student anxiety. A volunteer sample of 18 undergraduate psychology students participated. The students were pretested with a trait anxiety instrument, and on the basis of their scores, were classified as High Anxious or Low Anxious. Students within each anxiety category were then randomly assigned to receive either a take-home midterm examination or an in-class midterm examination. The researcher hypothesized that the ‘impact’ of test type would be greatest for the high anxiety students. On the day of the examination, the researcher administered a test anxiety instrument to obtain a measure of the students’ anxiety about taking the midterm. The following test anxiety scores were obtained:

 

Student Trait Anxiety

Type of Test

In-Class

Take-home

Low

 

22

16

21

17

 

 

20

18

22

High

21

35

33

25

25

28

 

24

23

19

21

22

data case3;

input trait $ 1 test 3 score 5-7;

datalines;

L 22

L 16

L 21

L 17

H 21

H 35

H 33

H 25

H 25

H 28

L 20

L 18

L 22

H 24

H 23

H 19

H 21

H 22

;

PROC ANOVA;

CLASS TRAIT TEST;

MODEL SCORE = TRAIT TEST TRAIT*TEST;

MEANS TRAIT TEST/TUKEY;

RUN;

 

 

 


Accepted Solutions
Solution
‎02-27-2016 09:31 PM
Contributor
Posts: 46

Re: Help with SAS Anova codes

I tried those codes Rick, and all it is giving me is a frequency table. These are my codes.
data case3;
input trait $ 1 test $ 3 count;
datalines;
L C 22
L C 16
L C 21
L C 17
H C 21
H C 35
H C 33
H C 25
H C 25
H C 28
H T 20
H T 18
H T 22
H T 24
H T 23
H T 19
H T 21
H T 22
;
PROC GLM data=case3;
CLASS TRAIT TEST;
MODEL SCORE = TRAIT TEST;
RUN;
proc print;
run;

View solution in original post


All Replies
SAS Super FREQ
Posts: 3,306

Re: Help with SAS Anova codes

After the DATA step, put

PROC PRINT; RUN;

 

You will see that although your description and the PROC ANOVA code use three variables, you are only creating two variables in the DATA step.

 

Contributor
Posts: 46

Re: Help with SAS Anova codes

Thank you for your insights Rick. I tried to change the data step to trait $ test $ class home; but it is giving me tons of other errors. By the way when I input the full question on the help board, it somehow failed to enter in-class and take-home data in two separate columns.
SAS Super FREQ
Posts: 3,306

Re: Help with SAS Anova codes

I think you need to code the in-class and take-home variable.

Maybe use 'C' for in-class and 'T' for take-home.

SAS Super FREQ
Posts: 3,306

Re: Help with SAS Anova codes

Maybe like this?

data case3;
input trait $1 test $3 score;
datalines;
L C 22
L C 16
L C 21
L C 17
H C 21
H C 35
H C 33
H C 25
H C 25
H C 28
L T 20
L T 18
L T 22
H T 24
H T 23
H T 19
H T 21
H T 22
;

I notice that this is an unbalanced design (some groups are different sizes than others).  For these data you'll want to use PROC GLM instead of ANOVA.

 

Contributor
Posts: 46

Re: Help with SAS Anova codes

Thank you very much Rick, I will try this...Josie
Solution
‎02-27-2016 09:31 PM
Contributor
Posts: 46

Re: Help with SAS Anova codes

I tried those codes Rick, and all it is giving me is a frequency table. These are my codes.
data case3;
input trait $ 1 test $ 3 count;
datalines;
L C 22
L C 16
L C 21
L C 17
H C 21
H C 35
H C 33
H C 25
H C 25
H C 28
H T 20
H T 18
H T 22
H T 24
H T 23
H T 19
H T 21
H T 22
;
PROC GLM data=case3;
CLASS TRAIT TEST;
MODEL SCORE = TRAIT TEST;
RUN;
proc print;
run;
Grand Advisor
Posts: 9,451

Re: Help with SAS Anova codes

 

data case3;
input trait $  test $  count;
datalines;
L C 22
L C 16
L C 21
L C 17
H C 21
H C 35
H C 33
H C 25
H C 25
H C 28
L T 20
L T 18
L T 22
H T 24
H T 23
H T 19
H T 21
H T 22
;
run;
/*Check mean std for each cell*/
proc tabulate data=case3;
class trait test;
var count;
table trait*test,count*(mean std n);
run;
/*Check main effect*/
proc glm data=case3;
class trait test;
model count=trait test/ss1 ss3;
run;
proc glm data=case3;
class trait test;
model count=test trait /ss1 ;
run;
/*Check full model*/
proc glm data=case3;
class trait test;
model count=trait|test/ss1 ss3;
run;








 

 

Source DF Type I SS Mean Square F Value Pr > F
trait 1 137.1544012 137.1544012 10.13 0.0067
test 1 48.9186983 48.9186983 3.61 0.0782
trait*test 1 52.0713450 52.0713450 3.84 0.0701
Source DF Type III SS Mean Square F Value Pr > F
trait 1 119.0187135 119.0187135 8.79 0.0103
test 1 26.6678363 26.6678363 1.97 0.1824
trait*test 1 52.0713450 52.0713450 3.84 0.0701

 

 

Both kind of ANOVA(SS1 SS3) show trait is significant , test and trait*test - (interactive effect) are NOT significant.

So there is NO significant influence of test administration practices (in-class testing vs. take-home testing) on student anxiety.

Contributor
Posts: 46

Re: Help with SAS Anova codes

Thank you again very much for your assistance Mr. Keshan, it is very much appreciated.
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 414 views
  • 3 likes
  • 3 in conversation