## Demo: Examining Categorical Association (Self-Paced)

In this demonstration, you use the Table Analysis node in a flow to test an association between the two categorical variables, Response and StatusCatStarAll. You also calculate measures of association such as Cramer's V statistic and the odds ratio to determine the strength of association.

Reminder: If you restarted your SAS session, or it has timed out due to inactivity, you must re-create the course libraries, LOCALLIB and VST. To do this, run the AssignLibrary flow.

1. In SAS Viya, launch SAS Studio by clicking the Applications menu button (the three-by-three grid in the upper left corner), expand ANALYTICS LIFE CYCLE, and click Develop Code and Flows.
2. In the navigation panel on the far left, click the Explorer button (second from top). Expand Files >Home > workshop > VST. Double-click AssignLibrary.flw to open it.
3. Click the Run button on the flow toolbar.

Demo Steps

1. In the work area, click the plus sign next to the open tabs to create a new tab. From the drop-down menu, choose Flow. Alternatively, select Flow from the New menu at the top left of SAS Studio.
2. Click on the Steps icon on the left side of the Navigation Pane. Under SAS Steps, Data (Input and Output), double click on Table.
3. In the work area, click on the Table step. At the bottom, under Table Properties, click the file cabinet next to the Library field. Click on VST under Libraries, then select the PVA_DONORS data on the right and click OK.
4. Under SAS Steps, expand Statistics, then double click on the Table Analysis step.
5. Next, move your mouse towards the edge of the PVA_DONORS node until the pointer becomes a hand icon. Click and drag an arrow from PVA_DONORS node to the box on the left side of the Table Analysis node (the input port). Now Table Analysis is connected to the PVA_DONORS data. Click the Arrange nodes button to visually organize the nodes within the flow.
6. Click on the Table Analysis node, then select the Data tab.
7. Under Row variables, click the plus sign and select the StatusCatStarAll variable. Then click OK to close the Column Selection window.
8. Again, click the plus sign next to Column variables and select the Response variable. Then click OK to close the Column Selection window.
9. On the Cell Statistics tab, under Frequencies, select Expected in addition to Observed.
10. Under Percentages, check the box for Row.
11. Under the Association Statistics tab, under Tests of Association, ensure that Chi-square statistics (including Pearson, likelihood ratio and Mantel-Haenszel…) is selected
12. Scroll down to Measures of Association and select Odds ratio and relative risk (for 2x2 tables).
13. On the Computation Options tab, select the option to Suppress plots.
14. Run the flow and save it to the VST folder as Categorical data analysis.flw.
15. Examine the results. The Results window displays the frequency table, which includes the cell frequency, expected frequency, and row percentage.

Examine the row frequency percentages for combinations of values of the two variables. You notice that the row percentages are different in each column, indicating a possible association between the two variables (Status Category Star All Months and Response). To assess whether the differences between the percentages of response to the campaign across the levels of the status category is greater than would be expected by chance, you need to evaluate the chi-square test results.

Because the p-value for the chi-square statistic is <.0001, which is below 0.05, you reject the null hypothesis at the 5% level and conclude that there is evidence of an association between StatusCatStarAll and Response. The Cramer's V statistic value of 0.1106 indicates that the association detected by the chi-square test is relatively weak. The Odds Ratio and Relative Risks table can also be used to measure the strength of association.

The odds ratio is shown in the first row of the table, along with the 95% confidence limits. To interpret the odds ratio, refer to the contingency table at the beginning of the output. The top row (StatusCatStarAll=0, in this case) is the numerator of the ratio, and the bottom row (StatusCatStarAll=1) is the denominator. The interpretation is stated in relation to the left column of the contingency table (Response=No). The value of 1.56 indicates that an individual with a StatusCatStarAll=0 value has about 1.56 times the odds of not responding to the campaign compared to an individual with StatusCatStarAll=1. This is equivalent to saying that an individual with StatusCatStarAll=1 has 1.56 times the odds of responding to the campaign compared with an individual with StatusCatStarAll=0.

Relative risk estimates for each column are interpreted as probability ratios rather than odds ratios. You get a choice of assessing probabilities of the left column (Column 1) or the right column (Column 2). For example, the Column 1 relative risk shows the ratio of the probabilities of StatusCatStarAll=0 to StatusCatStarAll=1 being in the left column (56 / 44.9 = 1.2472).