Creating a neat and reader-friendly SAS Chi-square test report
This macro is for performing chi-square test. Both var and byvar should be categorical variables. The macro would automatically convert a numeric variable into a character variable. Therefore there is no warning or error if you feed the macro with a continuous variable. If the Fisher test consumes too much time, you can manually set fisher=0 to suppress the Fisher test. The default fisher parameter(If not specify) is 1. Example: data example; set SASHELP.electric; if Revenue>60 then revenue_Group="A"; else revenue_Group="B"; if Year<2000 then time_group="A"; else time_group="B"; keep Customer revenue_Group time_group ; run; proc freq data=example; tables (time_group revenue_Group)*Customer/norow nocol nopercent; run; %INCLUDE "/folders/myshortcuts/SASfolder/Tools/Macro_ChiSqOrFisher.sas" ; %ChiSqOrFisher(table=example,var=time_group revenue_Group,Byvar=Customer,fisher=1); Result: Macro: %Macro ChiSqOrFisher(table=,var=,B...