Now that is a much simpler program! The output contains a lot more tests than we actually want though. What if we want just the tables and p-value for the chi-square test from each test, or just a single table with the p-values for each test. In general SAS is verbose and gives us a lot more output than we want. So we will need to select just the parts of the output that we want to make our reports.
Data Driven MACROS¶
Often, we will want to make our MACROS data driven, that means we will want our MACRO to perform different actions depending what data we have. To do this, we will need to use SYMPUT and SYMGET and to use conditional logic %IF/%THEN/%ELSE inside a MACRO.
For the next example, we will update our MACRO to only return the two by two table and either the adjusted chi-square p-value or Fisher's exact test p-value if the expected cell counts are less than 5.
First, we will need to write and test our code for selecting only the output we want before we make our updated macro. We want to run a continuity adjusted chi-square test or Fisher's exact test if the expected counts are too small. We only want the table with row percentages and the result of the correct test in our output.