Hello , I have 2 groups (endovascular and surgical ) each one has good outcome and bad outcome , how can I calculate chi square for the difference between the two groups ? I am inputing these in SAS:
data procedure;
input procedrue $ good_outcome bad_outcome ;
cards;
surgical 500 200
endovascular 300 150
;
run;
Thanks
@Khalid2015 wrote:
Hello , I have 2 groups (endovascular and surgical ) each one has good outcome and bad outcome , how can I calculate chi square for the difference between the two groups ? I am inputing these in SAS:
data procedure;
input procedrue $ good_outcome bad_outcome ;
cards;
surgical 500 200
endovascular 300 150
;
run;
Thanks
Chi-squares don't do 'difference between groups', they test difference in distributions between groups.
To do "difference between groups" you need to define how you are getting "difference".
Perhaps:
data procedure; input procedure $12. good_outcome bad_outcome; outcome='Good'; freq=good_outcome; output; outcome='Bad'; freq=bad_outcome; output; cards; surgical 500 200 endovascular 300 150 ; run; proc freq data=procedure; tables procedure*outcome/ chisq; weight freq; run;
Note creating a single variable with two levels from two variables. Using a frequency count to maintain the sample size information (more or less). This will generally be the better way to prepare data for most of the analysis procedures in SAS.
A CHI-SQUARE test can be requested by using the FREQ procedure:
data procedure;
input procedure $12. good_outcome bad_outcome;
cards;
surgical 500 200
endovascular 300 150
;
run;
proc freq data=work.procedure (where=(procedure="surgical")); /*or endovascular*/
table bad_outcome*good_outcome / chisq;
run;
hi qoit, I do not think this would solve. I need to compare surgical vs Endovacular. the "where" statemnt restricts one of the groups from the analysis
@Khalid2015 wrote:
Hello , I have 2 groups (endovascular and surgical ) each one has good outcome and bad outcome , how can I calculate chi square for the difference between the two groups ? I am inputing these in SAS:
data procedure;
input procedrue $ good_outcome bad_outcome ;
cards;
surgical 500 200
endovascular 300 150
;
run;
Thanks
Chi-squares don't do 'difference between groups', they test difference in distributions between groups.
To do "difference between groups" you need to define how you are getting "difference".
Perhaps:
data procedure; input procedure $12. good_outcome bad_outcome; outcome='Good'; freq=good_outcome; output; outcome='Bad'; freq=bad_outcome; output; cards; surgical 500 200 endovascular 300 150 ; run; proc freq data=procedure; tables procedure*outcome/ chisq; weight freq; run;
Note creating a single variable with two levels from two variables. Using a frequency count to maintain the sample size information (more or less). This will generally be the better way to prepare data for most of the analysis procedures in SAS.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.