BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Khalid2015
Calcite | Level 5

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 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@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.

View solution in original post

3 REPLIES 3
qoit
Pyrite | Level 9

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;
Khalid2015
Calcite | Level 5

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

ballardw
Super User

@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.

SAS Innovate 2025: Register Now

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!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 3 replies
  • 942 views
  • 7 likes
  • 3 in conversation