Hello,
This may sound like a very basic question... but,
I am working with a set of chemotherapy data that contains 3 types of chemotherapy and it would be really helpful if there is a way to run Chi-Squared Test in SAS without seperating the files.
My data and variables looks like the following:
Patient_ID=ID assigned to Patient
Chemo_Type=Type of Chemotherapy (1=type A, 2=type B, 3=type C)
Readmiited_YN=Readmission to Hospital after Chemotherapy (1=readmission, 0=no readmission),
Patient_ID Chemo_Type Readmitted_YN
10012 1 1
10013 2 0
10014 3 0
10015 2 1
10016 2 0
10017 3 1
10018 1 1
10019 2 1
.
.
.
(cont')
with this data set I have to do a run a chi-squared test for Chemo_Type=1 vs. Chemo_Type=2 & Chemo_Type=1 vs. Chemo_Type=3 (*I do NOT need to run a chi-squared test for Chemo_type=2 vs. Chemo_type=3)
Is there a way to run the chi-squared test for Chemo_Type=1 vs. Chemo_Type=2 & Chemo_Type=1 vs. Chemo_Type=3 with the current data set I have?
I am currently doing the following :
-------------------------------------------------------------------------------------------
data w.cancer_1vs2; set w.cancer; if Chemo_type=3 then delete;
proc freq data=w.cancer_1vs2;
tables Chemo_Type*Readmitted_YN/chisq;
run;
data w.cancer_1vs3; set w.cancer; if Chemo_type=2 then delete;
proc freq data=w.cancer_1vs3;
tables Chemo_Type*Readmitted_YN/chisq;
run;
---------------------------------------------------------------------------------------------
Is there a way to run this in a single file (w.cancer) without having to delete the undesired Chemo_Type for running Chi-Squared Test?
Thank you.
Yes. Most Procs support the WHERE statement.
Proc freq data = have;
Where chemo_type ne 3;
Table .../ chisq;
Run;
Proc freq data = have;
Where chemo_type ne 2;
Table ... / chisq;
Run;
Yes. Most Procs support the WHERE statement.
Proc freq data = have;
Where chemo_type ne 3;
Table .../ chisq;
Run;
Proc freq data = have;
Where chemo_type ne 2;
Table ... / chisq;
Run;
Thank you so much for your answer.
Your answer was really helpful.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.