BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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?
3 REPLIES 3
lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12
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.
lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12
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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1233 views
  • 0 likes
  • 2 in conversation