LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (November 2005, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 30 Nov 2005 03:28:52 -0800
Reply-To:     RolandRB <rolandberry@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         RolandRB <rolandberry@HOTMAIL.COM>
Organization: http://groups.google.com
Subject:      Re: Fisher's Test
Comments: To: sas-l@uga.edu
In-Reply-To:  <BAY103-F1087215090D4EEFAFEA37CB04A0@phx.gbl>
Content-Type: text/plain; charset="iso-8859-1"

David L Cassell wrote: > > I need to run the Fisher's Test on a dataset. In addition > >to the count, I also need the p-value. My code looks like this: > > > >proc freq data=3Dindata noprint; > > tables trtgrpi*racen/out=rac fisher; > >run; > > I assume you mean Fisher's exact test. In that case, you're on the right > track. > > I don't think this will give you your p-values, though. You want to use ODS > to > get that. You want somethign like this UNTESTED code: > > > ods output FishersExact=YourTable; > > proc freq data=3Dindata noprint; > tables trtgrpi*racen / fisher; > run; > > ods output close; > > > HTH, > David

This is part of the code I'm using. I've no idea if it is right though, not being a statistician.

%if "&dofisher" EQ "Y" %then %do;

ods output close; ods listing close; ods output FishersExact=_Fishers;

proc freq data=_pvaldsin; %if %length(&byvars) %then %do; by &byvars; %end; tables &trtvar*&respvar / exact sparse; run; ods listing;

%end;

data &dsout; merge %if "&dofisher" EQ "Y" %then %do; _Fishers(keep=&byvars Name1 nValue1 where=(Name1="XP2_FISH")) %end; _ChiSq(keep=&byvars Statistic Prob where=(Statistic="Chi-Square")) _expectsum ; %if %length(&byvars) %then %do; by &byvars; %end; %if "&dofisher" NE "Y" %then %do; nValue1=.; Name1=.; %end; if _test="FISHER" then _pvalue=nValue1; else if _test="CHISQ" then _pvalue=Prob; drop Statistic Name1 nValue1 Prob; run;

%end;


Back to: Top of message | Previous page | Main SAS-L page