turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- IF-THEN statement for chi square/fisher's exact te...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-05-2011 09:39 AM

Hi

Is it possible to use an IF-THEN statement for chi square tests?

For example, if statistical significance is determined at p < 0.05, then is there a way to sieve out those that have p values less than 0.05 and classify them as significant?

Is it possible to use an IF-THEN statement for chi square tests?

For example, if statistical significance is determined at p < 0.05, then is there a way to sieve out those that have p values less than 0.05 and classify them as significant?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-05-2011 10:28 AM

I assume you have a chi-square test for each of several groups, and that the groups are all stacked in the same data file. The specific approach will depend on which PROC you are using (FREQ, etc.). You should first be able to get the displayed output for each group (using by statement) for the desired PROC. The general instruction is to find the ODS output table name for the specific procedure that contains the test statistics, P values, etc. Store this table as a file, as explained for use of ODS, in general. Then, perform an IF-THEN operation on this file, and then print this new file.

Can't give more specific instructions until you first get the procedure running.

Can't give more specific instructions until you first get the procedure running.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-05-2011 10:49 AM

As a follow-up to my previous email, here is a quick way to do what I think you want. I took a sas program from a previous post I made (involving PROC FREQ), and changed the values for the second group. The program does the FIsher's exact test and stores the results in file fe. See the printout of the full file. Then I eliminated the extra lines and dropped the group that had P > 0.05, leaving one line in the file. See the printout for file fe2.

DATA a; *---from a previous post, but with numbers in group 2 changed;

INPUT group FLOWERS $ COLOURS $ COUNT ;

DATALINES;

1 A I 18

1 A II 15

1 A III 12

1 B I 44

1 B II 43

1 B III 34

1 C I 34

1 C II 31

1 C III 37

2 A I 5

2 A II 5

2 A III 12

2 B I 6

2 B II 47

2 B III 17

2 C I 10

2 C II 10

2 C III 8

;

proc print data=a;

RUN;

PROC FREQ data=a;

ods output fishersexact=fe;

by group;

WEIGHT COUNT;

TABLES flowers*colours;

EXACT FISHER;

RUN;

proc print data=fe; *---All results for Fisher;

run;

data fe2; set fe;

if (Name1 eq 'XP2_FISH');

if (cValue1 le 0.05);

proc print data=fe2; *---Show group with significant result (P < 0.05);

run;

DATA a; *---from a previous post, but with numbers in group 2 changed;

INPUT group FLOWERS $ COLOURS $ COUNT ;

DATALINES;

1 A I 18

1 A II 15

1 A III 12

1 B I 44

1 B II 43

1 B III 34

1 C I 34

1 C II 31

1 C III 37

2 A I 5

2 A II 5

2 A III 12

2 B I 6

2 B II 47

2 B III 17

2 C I 10

2 C II 10

2 C III 8

;

proc print data=a;

RUN;

PROC FREQ data=a;

ods output fishersexact=fe;

by group;

WEIGHT COUNT;

TABLES flowers*colours;

EXACT FISHER;

RUN;

proc print data=fe; *---All results for Fisher;

run;

data fe2; set fe;

if (Name1 eq 'XP2_FISH');

if (cValue1 le 0.05);

proc print data=fe2; *---Show group with significant result (P < 0.05);

run;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-06-2011 04:51 AM

thank you!