12-13-2016 01:41 PM
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??
12-13-2016 02:18 PM
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.
12-13-2016 02:51 PM
12-13-2016 08:30 PM
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;