chi square test aggregated data file of P values

Reply
Occasional Contributor
Posts: 8

chi square test aggregated data file of P values

 I want to generate an aggregated sas or (excel file, if it is easier this way): 

 Question: data file I have here

 

          events_White Total_White  events_Black  total_Black  event_hispanic total_hispanic
risk01    20                   1200                 35                 980                   15               720
risk02    45                   1200                 50                 980                    21              720
risk03  100                   1200                 90                 980                    55              720

 

Can I do a chi square test on the events counts by race (white, black, hispanic) using the event counts and totals of each group, and eventually get an output data file as the following, basically, only the P values?? what would be the appropriate sas code??

 

           chi_P
risk01      ?
risk02      ?
risk03      ?

 

Thanks. 

 

Joy

SAS Super FREQ
Posts: 3,620

Re: chi square test aggregated data file of P values

Could you be more specific  and explain what each cell means? For example, were there 1500 whites in the entire sample, or were there 1500 in each risk category?

 

Do you want a test of association/independence? Or are you testing for something else?

 

If y ou are familiar with the concept of "null  hypothesis," you could state that. Otherwise use words.

 

Occasional Contributor
Posts: 8

Re: chi square test aggregated data file of P values

Thanks for asking and helping.

Yes, the totals are how many subject in the study. for each race, the total
is the same for each risk factors (risk01-risk03).
Hypothesis:

H0=the frequency/proportion of the risk factor (e.g. risk01) in different
races is the same
H1= the frequency/proportion of the risk factor (e.g. risk01) in different
races is different

##- Please type your reply above this line. Simple formatting, no
attachments. -##
SAS Super FREQ
Posts: 3,620

Re: chi square test aggregated data file of P values

The format of your data needs to be modified. Instead of events and total, you want events and nonevents.  You should also move from wide data to long data. 

 

Here is one way to get the chi-square test of homogeneity for each level of risk:

Data A;
length Level $6 Race $8 Response $3; 
input Level $ Race $ Response $ Count;
datalines;
risk01 White    Yes   20
risk01 White    No  1180
risk01 Black    Yes   35
risk01 Black    No   945
risk01 Hispanic Yes   15
risk01 Hispanic No   705
risk02 White    Yes   45
risk02 White    No  1155
risk02 Black    Yes   50
risk02 Black    No   930
risk02 Hispanic Yes   21
risk02 Hispanic No   699
risk03 White    Yes  100
risk03 White    No  1100
risk03 Black    Yes   90
risk03 Black    No   890
risk03 Hispanic Yes   55
risk03 Hispanic No   665
;

proc freq data=A;
weight Count;
table  Level * Race * Response / chisq;  /* or use BY LEVEL instead */
output out=Out chisq;
run;

proc print data=Out label;
var Level N _PCHI_ DF_PCHI  P_PCHI;
run;
Ask a Question
Discussion stats
  • 3 replies
  • 196 views
  • 1 like
  • 2 in conversation