BookmarkSubscribeRSS Feed
abou55
Calcite | Level 5

 

For example:

 

How to conduct comparison tests to compare the averages of y1scores for x2 at levels 1 and 2 for each level of x1 (x1=1 and x1=2). That is

For x1=1: y1scores average (at x2=1) versus y1scores average (at x2=2)

For x1=2: y1scores average (at x2=1) versus y1scores average (at x2=2)

 

And same thing for x3 and x4

Also same thing for y2scores, y3scores, and y4scores.

 

Please see the SAS code below.

 

With many thanks in advance

Abou

 

------------  SAS Program and Data   -------------

 

data data1;
input x1$ x2$ x3$ x4$ y1scores y2scores y3scores y4scores;
datalines;
1 2 1 2 8.22 5.50 8.58 6.89
1 2 1 2 5.60 4.41 6.90 6.20
1 2 1 1 6.44 6.73 6.32 5.78
1 2 1 1 4.77 5.33 5.97 6.96
1 2 1 1 6.83 6.79 7.29 7.87
1 2 2 2 12.98 9.04 9.41 10.43
1 2 1 2 5.85 9.00 8.65 6.30
1 2 1 2 8.03 7.43 7.47 8.66
1 1 2 2 4.84 5.52 4.81 4.44
1 2 1 2 7.21 6.63 6.33 7.32
1 2 1 1 16.36 10.46 7.85 11.28
1 2 2 2 8.37 7.40 9.66 9.99
1 2 1 1 6.78 4.60 5.62 6.60
1 2 2 2 10.37 7.14 9.98 8.69
1 2 1 2 8.43 7.54 7.56 7.75
1 2 1 2 6.23 5.80 6.20 5.99
1 2 2 2 10.20 6.00 8.49 10.49
1 2 1 2 8.66 5.42 6.48 8.57
1 2 1 1 6.98 5.28 4.39 7.06
1 2 1 1 4.70 4.96 4.89 7.58
1 2 2 2 11.42 8.80 11.10 10.46
1 2 2 2 7.73 7.42 9.38 8.28
1 2 1 1 9.81 6.00 10.08 7.15
1 2 1 2 4.61 3.79 6.42 5.55
1 1 1 2 9.83 12.17 15.41 17.03
1 2 1 2 3.33 3.19 3.49 5.07
1 2 1 2 5.08 3.91 4.89 4.35
1 2 2 2 5.38 6.00 5.89 4.69
1 2 1 2 4.92 4.91 6.54 5.57
1 2 1 2 7.65 9.91 12.54 8.83
1 2 1 2 8.46 9.31 8.71 8.53
1 2 2 2 4.62 4.17 4.77 5.95
1 2 2 1 7.67 6.12 6.79 6.36
1 2 1 1 6.52 4.83 5.59 6.00
1 2 2 2 5.48 4.50 5.66 6.15
1 2 1 2 4.93 4.80 6.17 6.48
1 2 1 1 8.31 6.22 6.67 10.73
2 2 1 1 7.24 7.64 11.59 6.86
1 2 1 1 3.91 2.94 4.27 3.21
2 2 1 2 8.58 7.80 7.87 6.87
2 2 1 2 7.96 3.14 3.77 5.88
1 2 1 1 6.77 7.85 7.49 5.72
2 2 1 1 8.03 11.74 6.99 6.53
2 2 1 1 8.92 6.91 6.77 10.05
1 1 2 2 12.02 7.33 7.22 12.37
1 2 1 1 5.96 3.80 3.98 6.83
1 2 2 1 7.70 5.45 7.93 6.06
2 2 1 1 5.89 4.77 5.67 9.72
2 2 1 2 9.64 10.80 8.61 10.20
2 2 1 1 7.08 5.12 5.94 4.97
2 2 1 1 7.95 6.19 6.60 6.14
2 2 1 1 9.30 4.75 6.47 5.64
2 2 2 2 15.43 8.71 9.14 17.98
2 2 1 1 4.20 5.99 4.47 4.23
2 2 1 1 7.09 8.35 6.74 7.18
1 1 2 2 7.42 5.97 6.45 6.65
2 2 1 1 6.70 5.86 7.93 10.36
2 2 1 2 9.37 7.44 14.35 17.63
2 2 1 1 6.36 4.75 4.39 6.78
1 1 2 2 9.82 5.46 15.79 10.71
1 2 1 2 4.36 4.60 5.36 5.77
2 2 1 1 6.69 8.05 6.46 8.30
2 2 1 1 6.77 5.23 6.16 5.48
1 2 1 1 4.14 3.42 4.99 4.32
2 2 1 1 14.39 5.84 4.88 7.29
1 2 1 2 9.58 8.19 17.33 9.09
2 2 1 1 6.29 5.09 5.56 5.44
2 2 1 1 16.09 11.37 14.84 9.77
1 2 1 2 10.39 6.12 7.76 8.35
1 1 2 2 11.07 12.48 8.99 10.74
1 2 1 1 6.28 4.35 6.12 6.50
1 2 1 1 5.83 4.45 6.89 6.39
1 2 1 2 4.35 5.43 3.96 4.32
1 2 1 1 15.06 9.03 8.32 7.43
2 2 1 2 4.22 3.78 5.40 5.51
1 2 1 2 5.98 5.00 5.83 4.67
1 2 1 2 5.04 3.69 5.42 4.93
1 2 1 2 4.14 4.13 5.20 5.07
1 2 1 2 6.00 5.11 5.87 4.94
1 2 1 2 6.25 5.35 5.51 6.39
1 2 2 2 5.59 5.98 8.54 5.20
1 1 2 2 8.63 5.86 7.27 6.80
1 2 1 2 7.82 6.61 7.57 7.41
1 2 1 2 9.01 10.33 12.48 11.40
2 2 1 1 6.73 5.09 5.65 6.52
2 2 1 1 9.80 5.75 8.36 6.85
1 2 1 2 7.14 6.23 7.67 8.22
1 2 1 2 5.37 3.76 6.05 6.61
2 2 1 1 13.25 7.85 14.67 14.60
1 2 1 1 3.80 4.11 4.20 5.10
2 2 1 1 6.28 5.96 4.59 4.70
2 2 2 2 6.00 5.44 6.19 6.75
2 2 1 1 7.41 6.57 8.74 10.00
2 2 1 2 7.33 7.88 9.08 7.64
2 2 1 2 14.97 8.95 16.24 13.83
2 2 1 2 4.88 4.44 5.89 6.89
2 2 1 1 5.92 5.84 6.90 7.54
2 2 1 1 5.77 7.68 6.03 7.08
2 2 1 1 5.66 4.83 6.31 7.25
1 2 1 1 4.49 3.42 4.13 3.09
2 2 1 1 11.19 8.05 10.61 10.36
2 2 1 2 5.27 4.04 4.57 8.63
2 2 1 2 6.93 5.63 5.83 8.11
2 2 1 2 5.11 4.12 8.19 6.52
2 2 1 2 14.92 10.73 12.58 17.11
2 2 1 2 6.01 5.82 6.22 7.90
2 2 1 1 8.05 6.45 5.36 6.25
2 2 1 1 7.55 5.41 7.48 8.67
2 2 1 1 6.45 5.48 7.85 7.48
2 2 1 1 5.28 4.75 5.81 5.59
2 2 1 1 5.65 5.32 6.21 7.23
1 2 1 1 6.85 5.98 8.89 8.94
2 2 1 1 9.33 5.94 10.94 7.17
2 2 1 1 7.89 5.24 7.31 9.39
2 2 1 1 7.93 10.11 11.77 14.54
2 2 1 2 5.67 6.11 5.36 6.30
1 2 1 1 7.50 5.99 5.50 7.21
1 2 1 2 7.32 6.86 7.11 6.73
1 2 1 2 9.72 9.99 14.04 10.42
2 2 1 1 12.80 5.30 7.41 6.39
1 2 1 2 9.18 8.26 6.70 8.22
1 2 2 2 12.03 8.92 12.87 10.07
1 2 1 1 4.33 4.43 4.91 4.84
1 2 1 2 9.21 8.11 8.71 9.41
2 2 1 1 8.00 5.47 6.46 8.10
;
run;


proc print data = data1;
run;


/*  MANOVA Model  */

PROC GLM DATA = data1;
CLASS x1 x2 x3 x4;
MODEL y1scores y2scores y3scores y4scores = x1 | x2 | x3 | x4 @2;
MANOVA H = _ALL_ ;
run;



/*  Sort data1 by x1  */

proc sort data=data1 out = data1sort;
by x1;
run;

 
 

 

 

2 REPLIES 2
jiltao
SAS Super FREQ

You could use the LSMEANS statement in PROC GLM. For example,

lsmeans x1*x2 / slice=x1 diff;

You could get the test for the x2 effect for each level of x1 for y1score to y4score respectively.

The problem here is with your data. Many of the LSMEANS are nonestimable, so the LSMEANS statement above will probably not produce anything useful.

The reasons for nonestimable LSMEANS in your case might be --

1. There is an empty cell for x1*x2 which makes some lsmeans non-estimable. (I did not look at all other two way interactions so there might be other interaction terms with empty cells too).

2. You have confoundings in your data/model, so some effects have 0 df and therefore cannot be tested. This is indicated in the Log --

NOTE: H Matrix for x1*x2 has zero d.f.

NOTE: H Matrix for x2*x4 has zero d.f.

As a matter of fact, if you add the E option in the MODEL statement you will see the General Form of Estimable Functions table, which confirms the confounding in your data/model.

You might want to remove the effects that are confounded with other effects in the model. For example,

 

PROC GLM DATA = data1;
CLASS x1 x2 x3 x4;
MODEL y1scores y2scores y3scores y4scores = x1 x2 x3 x4 x1*x3 x1*x4 x2*x3 x3*x4 ;
MANOVA H = _ALL_ ;
lsmeans x1*x3 / slice=x1 diff;
lsmeans x1*x4 / slice=x1 diff;
run;
quit;

abou55
Calcite | Level 5

Dear All:

 

Thank you very much for your help with this problem.

 

with many thanks

abou

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 2 replies
  • 436 views
  • 1 like
  • 2 in conversation