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.
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
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
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".
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.