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


I'd like to perform all unique combinations of pairwise Student's t-test comparisons of average length of stay between a family of 31 hospitals, and then output the p-values for each test (with the goal of plotting the ordered p-values to help estimate the # of true null hypotheses according to Schweder and Spjotvoll (1982)).

Is there a simple way to do this with proc multtest without specifiying all possible contrasts with multiple CONTRAST statements? I want to avoid this:

proc multtest data=hospital;

     class hospital_name;

     test mean(los);

     contrast 'A vs B' (-1 1 0 0 ... 0);

     contrast 'A vs C' (-1 0 1 0 ... 0);

     contrast 'B vs C' (0 -1 1 0 ... 0);

     ...

     contrast 'A vs Z' (1 0 0 0 ... -1);

run;

I've checked the online manual for proc multtest and it isn't terribly helpful.

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Proc GLM has the ability to do all pairwise comparisons and correct p-values for test multiplicity. You will have to do a bit of reformatting of the results as in the following example::

proc glm data=sashelp.baseball plots=none;

class team;

model nRuns = team;

*lsmeans team / pdiff adjust=simulate;       /* Corrected p-values */

lsmeans team / pdiff adjust=t;                      /* Uncorrected p-values */

ods output Diff=teamDiffs LSMeans=teamLSMeans;

run; quit;

proc transpose data=teamDiffs out=teamDiffsLong;

by rowName;

var _:;

run;

proc sql;

create table teamDiffsPList as

select

    b.team as team,

    c.team as withTeam,

    a.COL1 as tProb

from

    teamDiffsLong as a inner join

    teamLSMeans as b on left(a.rowName) = cats(b.LSMeanNumber) inner join

    teamLSMeans as c on a._NAME_ = cats("_", c.LSMeanNumber)

where input(a.rowName, best.) > input(substr(a._NAME_,2), best.)

order by tProb;

quit;

PG

PG

View solution in original post

2 REPLIES 2
PGStats
Opal | Level 21

Proc GLM has the ability to do all pairwise comparisons and correct p-values for test multiplicity. You will have to do a bit of reformatting of the results as in the following example::

proc glm data=sashelp.baseball plots=none;

class team;

model nRuns = team;

*lsmeans team / pdiff adjust=simulate;       /* Corrected p-values */

lsmeans team / pdiff adjust=t;                      /* Uncorrected p-values */

ods output Diff=teamDiffs LSMeans=teamLSMeans;

run; quit;

proc transpose data=teamDiffs out=teamDiffsLong;

by rowName;

var _:;

run;

proc sql;

create table teamDiffsPList as

select

    b.team as team,

    c.team as withTeam,

    a.COL1 as tProb

from

    teamDiffsLong as a inner join

    teamLSMeans as b on left(a.rowName) = cats(b.LSMeanNumber) inner join

    teamLSMeans as c on a._NAME_ = cats("_", c.LSMeanNumber)

where input(a.rowName, best.) > input(substr(a._NAME_,2), best.)

order by tProb;

quit;

PG

PG
RobF
Quartz | Level 8

Fantastic, thank you PGStats!

BTW I also edited the format of the p-values from PVALUEw.d format to 12.8 numerical format to avoid values of "<.001".

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 Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1371 views
  • 1 like
  • 2 in conversation