BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jmoseley
Quartz | Level 8

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;

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jmoseley
Quartz | Level 8
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

8 REPLIES 8
Rick_SAS
SAS Super FREQ

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.

 

jmoseley
Quartz | Level 8
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.
Rick_SAS
SAS Super FREQ

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

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

Rick_SAS
SAS Super FREQ

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.

 

jmoseley
Quartz | Level 8
Thank you very much Rick, I will try this...Josie
jmoseley
Quartz | Level 8
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;
Ksharp
Super User

 

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.

jmoseley
Quartz | Level 8
Thank you again very much for your assistance Mr. Keshan, it is very much appreciated.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

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