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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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