BookmarkSubscribeRSS Feed
echoli
Obsidian | Level 7

Hi All,

 

I am trying to do pairwise comparisons to see the difference of means within each two groups (I have four groups totally). But in the SAS output below, the last column shows which group comparison is significant or not. But I want to get the p-value of the last column, not just star signs. Any idea?

Here is my output Table:

Comparisons significant at the 0.05 level are indicated by ***.

group
Comparison

Difference
Between
Means

Simultaneous 95% Confidence Limits

 

(1) Toddler - (2) Young

8.862

0.592

17.131

***

(1) Toddler - (3) Child

16.756

8.674

24.838

***

(1) Toddler - (4) Teen

20.183

11.744

28.621

***

(2) Young   - (1) Toddler

-8.862

-17.131

-0.592

***

(2) Young   - (3) Child

7.894

0.574

15.214

***

(2) Young   - (4) Teen

11.321

3.608

19.033

***

(3) Child   - (1) Toddler

-16.756

-24.838

-8.674

***

(3) Child   - (2) Young

-7.894

-15.214

-0.574

***

(3) Child   - (4) Teen

3.427

-4.084

10.938

 

(4) Teen    - (1) Toddler

-20.183

-28.621

-11.744

***

(4) Teen    - (2) Young

-11.321

-19.033

-3.608

***

(4) Teen    - (3) Child

-3.427

-10.938

4.084

 

 

Here is my code:

 

proc anova data=combine;
class group;
model variable = group;
means group / BON;
run;

 

proc glm data=combine;
class group;
model variable = group;
means group / bon;
run;

 

 

Thanks,

C

2 REPLIES 2
Rick_SAS
SAS Super FREQ

use

lsmeans group / pdiff adjust=bon; /* or another adjust= option */

 

Complete example:

 


proc glm data=sashelp.cars;
class type;
model mpg_city = type;
lsmeans type / pdiff adjust=bon;
run;

The doc shows many ways to adjust the p-values for multiplicity.  I like Bonferonni and SIMULATE.

echoli
Obsidian | Level 7

Hi Rick,

 

Yes, I got this way before, but in this way, SAS outputs P-value table in as a matrix (as shown below). Then I have to write a long code to reorganize the p-values along with group comparison so they can display as one column (as the last column in the table shown in my question). I think that's a complex way....

Least Squares Means for effect group
Pr > |t| for H0: LSMean(i)=LSMean(j)

Dependent Variable: Variable

i/j

1

2

3

4

1

 

0.0047

<.0001

<.0001

2

0.0047

 

0.0045

0.0001

3

<.0001

0.0045

 

0.2270

4

<.0001

0.0001

0.2270

 

 

Any way to show the p_values in the last column instead of star signs like in the below table directly?

Comparisons significant at the 0.05 level are indicated by ***.

group
Comparison

Difference
Between
Means

95% Confidence Limits

 

(1) Toddler - (2) Young

8.862

2.732

14.992

***

(1) Toddler - (3) Child

16.756

10.764

22.747

***

(1) Toddler - (4) Teen

20.183

13.927

26.438

***

(2) Young   - (1) Toddler

-8.862

-14.992

-2.732

***

(2) Young   - (3) Child

7.894

2.467

13.320

***

(2) Young   - (4) Teen

11.321

5.604

17.038

***

(3) Child   - (1) Toddler

-16.756

-22.747

-10.764

***

(3) Child   - (2) Young

-7.894

-13.320

-2.467

***

(3) Child   - (4) Teen

3.427

-2.141

8.995

 

(4) Teen    - (1) Toddler

-20.183

-26.438

-13.927

***

(4) Teen    - (2) Young

-11.321

-17.038

-5.604

***

(4) Teen    - (3) Child

-3.427

-8.995

2.141

 

 

Thanks,

C

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
  • 2 replies
  • 3885 views
  • 0 likes
  • 2 in conversation