Date: Mon, 9 Apr 2012 08:07:35 -0500
Reply-To: Warren Schlechte <Warren.Schlechte@TPWD.STATE.TX.US>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Warren Schlechte <Warren.Schlechte@TPWD.STATE.TX.US>
Subject: Re: t test (more than two categories)
Content-Type: text/plain; charset="us-ascii"
This won't get you exactly what you want, but it will get you what you
need.
Proc glm data= ttesttry;
Class series;
Model series=Fe;
Lsmeans series/pdiff=all;
Run;
Two issues that you might wish to be aware of. First, when running
multiple t-tests, the alpha error level is inflated.
(See http://grants.hhp.uh.edu/doconnor/PEP6305/Multiple%20t%20tests.htm)
It is typical to adjust the error to account for this issue by adding an
option to the lsmeans statement. For example:
Lsmeans series/pdiff=all adjust=tukey;
Second, the (example) data provided do not appear to come from a normal
distribution. You may wish to consider whether these data are
appropriately analyzed with a parametric test. An alternative would be
to run a nonparametric ANOVA. For example:
Proc npar1way data=ttesttry wilcoxon;
Class series;
Var Fe;
Run;
To get pairwise comparisons for a nonparametric test, I suggest you see:
http://www.lexjansen.com/pharmasug/2004/statisticspharmacokinetics/sp04.
pdf
A second alternative would be to rank the data and use the ranked data
in Proc GLM or MULTTEST.
(See http://support.sas.com/kb/22/620.html)
HTH,
Warren Schlechte
-----Original Message-----
From: Ali Zanaty [mailto:zanaty2005@YAHOO.COM]
Sent: Sunday, April 08, 2012 11:00 AM
Subject: Re: t test (more than two categories)
Dear David:
For example, if I changed the data little bit (please see below). Can I
have something like this in the SAS output:
series N Mean Grouping
Telos 32 62217 A
Monson 19 23338 A B
Ragmuff 48 8099 B
Adams 9 802 B
Means that do not share a letter are significantly different.
/* ===================================== */
DM "clear log";
DM "clear output";
data ttesttry;
input series $ Fe;
cards;
Monson 8798
Monson 41239
Monson 30525
Adams 2103
Adams 2434
Adams 456
Adams 222
Adams 333
Adams 111
Adams 541
Adams 234
Adams 780
Telos 89056
Telos 8904
Telos 47956
Telos 76890
Telos 345678
Telos 189045
Telos 533799
Monson 2643
Monson 10212
Monson 42032
Monson 32296
Monson 5998
Monson 6745
Monson 48699
Monson 41491
Monson 36275
Ragmuff 345
Ragmuff 679
Ragmuff 345
Ragmuff 679
Ragmuff 234
Ragmuff 902
Ragmuff 450
Ragmuff 245
Ragmuff 555
Ragmuff 232
Ragmuff 765
Ragmuff 560
Ragmuff 345
Ragmuff 223
Ragmuff 568
Ragmuff 657
Ragmuff 777
Ragmuff 345
Ragmuff 980
Ragmuff 1111
Monson 4486
Monson 6095
Monson 13724
Monson 36232
Monson 32603
Monson 34271
Telos 3578
Telos 12502
Telos 43698
Telos 29935
Telos 30257
Ragmuff 3382
Ragmuff 16305
Ragmuff 50066
Ragmuff 29794
Ragmuff 27665
Ragmuff 7943
Ragmuff 8697
Ragmuff 53536
Ragmuff 48712
Ragmuff 37874
Ragmuff 33876
Ragmuff 34439
Telos 22580
Telos 8375
Telos 8925
Telos 38031
Telos 30286
Telos 31498
Telos 34652
Telos 32046
Ragmuff 234
Ragmuff 670
Ragmuff 111
Ragmuff 222
Ragmuff 333
Ragmuff 341
Ragmuff 483
Ragmuff 502
Ragmuff 4679
Ragmuff 5979
Ragmuff 9417
Ragmuff 345
Ragmuff 234
Ragmuff 801
Ragmuff 457
Ragmuff 678
Telos 10692
Telos 8383
Telos 46456
Telos 38227
Telos 34054
Telos 38084
Telos 15528
Telos 42748
Telos 38273
Telos 34787
Telos 31575
Telos 34431
Monson 9064
;
run;
proc mixed data=ttesttry;
class series;
model Fe=series;
lsmeans series/diff cl;
run;
/* ===================================== */
Thank you very much
Ali
--- On Sun, 4/8/12, Steenhard, David D. (LNG-HBE)
<david.steenhard@lexisnexis.com> wrote:
From: Steenhard, David D. (LNG-HBE) <david.steenhard@lexisnexis.com>
Subject: RE: t test (more than two categories)
To: "Ali Zanaty" <zanaty2005@YAHOO.COM>, "SAS-L@LISTSERV.UGA.EDU"
<SAS-L@LISTSERV.UGA.EDU>
Date: Sunday, April 8, 2012, 2:46 PM
Try using:
proc mixed data=ttesttry;
class series;
model Fe=series;
lsmeans series/diff cl;
run;
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
David D Steenhard
Marketing Analytics Manager
LexisNexis
Louisville , KY 40245
david.steenhard@lexisnexis.com
502-254-2310 Work
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Ali
Zanaty
Sent: Sunday, April 08, 2012 10:36 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: t test (more than two categories)
Dear All:
I need to run the t test for independent samples. The categorical
variable "series" has four categories.
But I still need to the run the t test on each pairs. How I can do this
with SAS.
Also I need the SAS output to include only the value of means, mean
difference, sample sizes, t test statistic, p-value of the test.
Here what I did:
============
data ttesttry;
input series $ Fe;
cards;
Monson 9064
Monson 8798
Monson 41239
Monson 30525
Adams 2103
Adams 2434
Adams 4819
Adams 38199
Adams 28973
Adams 27639
Adams 26766
Adams 28312
Adams 24365
Telos 3710
Telos 5780
Telos 47956
Telos 37528
Telos 29571
Telos 27496
Telos 33799
Monson 2643
Monson 10212
Monson 42032
Monson 32296
Monson 5998
Monson 6745
Monson 48699
Monson 41491
Monson 36275
Ragmuff 4674
Ragmuff 8231
Ragmuff 46917
Ragmuff 32904
Ragmuff 32835
Ragmuff 36570
Ragmuff 2177
Ragmuff 4702
Ragmuff 15321
Ragmuff 63092
Ragmuff 50571
Ragmuff 2936
Ragmuff 2015
Ragmuff 16900
Ragmuff 8134
Ragmuff 40882
Ragmuff 36707
Ragmuff 36739
Ragmuff 35405
Ragmuff 35097
Monson 4486
Monson 6095
Monson 13724
Monson 36232
Monson 32603
Monson 34271
Telos 3578
Telos 12502
Telos 43698
Telos 29935
Telos 30257
Ragmuff 3382
Ragmuff 16305
Ragmuff 50066
Ragmuff 29794
Ragmuff 27665
Ragmuff 7943
Ragmuff 8697
Ragmuff 53536
Ragmuff 48712
Ragmuff 37874
Ragmuff 33876
Ragmuff 34439
Telos 22580
Telos 8375
Telos 8925
Telos 38031
Telos 30286
Telos 31498
Telos 34652
Telos 32046
Ragmuff 11307
Ragmuff 16240
Ragmuff 13435
Ragmuff 60698
Ragmuff 48711
Ragmuff 47354
Ragmuff 48362
Ragmuff 50071
Ragmuff 4679
Ragmuff 5979
Ragmuff 9417
Ragmuff 53864
Ragmuff 47813
Ragmuff 45476
Ragmuff 45570
Ragmuff 46845
Telos 10692
Telos 8383
Telos 46456
Telos 38227
Telos 34054
Telos 38084
Telos 15528
Telos 42748
Telos 38273
Telos 34787
Telos 31575
Telos 34431
;
run;
proc print data = ttesttry;
run;
proc ttest data=ttesttry;
class series;
var Fe;
run;
============
ERROR: The CLASS variable has more than two levels.
Thank you very much.
Ali