Help using Base SAS procedures

how to create a table in SAS to perform a chi square test

Reply
Occasional Contributor
Posts: 6

how to create a table in SAS to perform a chi square test

[ Edited ]

Hi. 

I have this table below and I am trying to put the data in SAS to do some analysis.

Screen Shot 2017-09-24 at 1.32.35 PM.png

I am completly new in SAS so I am not sure the code I have below works fine.


DATA placeboStudy;
INPUT value Revascularization $ Treatment $ Study $;
DATALINES;
2 yes Niacin FATS
11 yes Placebo FATS
4 yes Niacin AFREGS
12 yes Placebo AFREGS
1 yes Niacin ARBITER 2
4 yes Placebo ARBITER 2
1 yes Niacin HATS
6 yes Placebo HATS
2 yes Niacin CLAS 1
1 yes Placebo CLAS 1
46 no Niacin FATS
41 no Placebo FATS
67 no Niacin AFREGS
60 no Placebo AFREGS
86 no Niacin ARBITER 2
76 no Placebo ARBITER 2
37 no Niacin HATS
32 no Placebo HATS
92 no Niacin CLAS 1
93 no Placebo CLAS 1
;
RUN;

 

I know how to work with R. I have tried to put the entries in R and did Chi square test. However, when I tried this code in SAS and performed chi square test, I got different results. What do you think is wrong with the code above?

 

* the question i am trying to asnwer is whether the patients on niacin developed coronary artery revascularization more than patiens onPlacebo. The sas results I obtain with this code should a p value greater than 0.05 which seems to be incorrect.

Thank you very much.

Super User
Posts: 10,774

Re: how to create a table in SAS to perform a chi square test

Posted in reply to Sara73737
you have three category variables.
and some cell freq < 5, so need Fisher exact test.




DATA placeboStudy;
INPUT value Revascularization $ Treatment $ Study $;
DATALINES;
2 yes Niacin FATS
11 yes Placebo FATS
4 yes Niacin AFREGS
12 yes Placebo AFREGS
1 yes Niacin ARBITER 2
4 yes Placebo ARBITER 2
1 yes Niacin HATS
6 yes Placebo HATS
2 yes Niacin CLAS 1
1 yes Placebo CLAS 1
46 no Niacin FATS
41 no Placebo FATS
67 no Niacin AFREGS
60 no Placebo AFREGS
86 no Niacin ARBITER 2
76 no Placebo ARBITER 2
37 no Niacin HATS
32 no Placebo HATS
92 no Niacin CLAS 1
93 no Placebo CLAS 1
;
RUN;
proc freq data=placeboStudy;
table Study*Revascularization*Treatment/cmh chisq  CELLCHI2 cmh2 fisher;
exact fisher;
weight value;
run;

Ask a Question
Discussion stats
  • 1 reply
  • 146 views
  • 0 likes
  • 2 in conversation