SAS: Getting 2×2 contingency table variables in the right order with PROC FREQ

By default, SAS will format a 2×2 contingency table like this if you have 1=yes 0=no binary variables:

|           | outcome=0 | outcome=1 |
|-----------|-----------|-----------|
| exposed=0 |           |           |
| exposed=1 |           |           |


But we want it like this:

|           | outcome=1 | outcome=0 |
|-----------|-----------|-----------|
| exposed=1 |           |           |
| exposed=0 |           |           |


The following code demonstrates how to do this:


And here's the output from this code: