The crossTab action performs one-way or two-way tabulations, also known as frequency counts. It can compute various statistics such as chi-square tests for independence and measures of association. This action is useful for understanding the distribution and relationship between categorical variables.
| Parameter | Description |
|---|---|
| acrossBy | When set to True, the levels of row and column variables are the same across the group-by variables. |
| aggregator | Specifies the aggregator for which the values of the weight variable are rolled up into a rank order score if a weight variable is specified. Values include 'CSS', 'CV', 'KURTOSIS', 'MAX', 'MEAN', 'MIN', 'N', 'NMISS', 'PROBT', 'SKEWNESS', 'STD', 'STDERR', 'SUM', 'TSTAT', 'USS', 'VAR'. |
| association | When set to True, measures of association between the row and column variable of the crosstabulation are computed. |
| chiSq | When set to True, chi-square statistics are computed for the test of independence of the row and column variables and their asymptotic p-values. |
| col | Specifies the column variable for the crosstabulation. |
| colFormat | Specifies a format for the column variable. |
| colNBins | Specifies the number of bins to use in binning the column variable. |
| descending | When set to True, the formatted levels of the variables are arranged in descending order. |
| fullTable | When set to True, a full-table scan is performed. |
| groupByLimit | Specifies the maximum number of levels in a group-by set. When the server determines this number of levels, the server stops and does not return a result. |
| includeMissing | When set to True, missing values are included in the crosstabulation. |
| niceBinning | When set to True, the nice binning algorithm is used. |
| orderByGbyRaw | When set to True, the ordering of the group-by variables is based on the raw values of the variables, not the formatted values. |
| row | Specifies the row variable for the crosstabulation. |
| rowFormat | Specifies a format for the row variable. |
| rowNBins | Specifies the number of bins to use in binning the row variable. |
| table | Specifies the input CAS table for the analysis. |
| weight | Specifies the numeric weight variable used to compute the statistics in the table cell and in the margins of the table. |
The following code creates the 'cars' table in the 'casuser' caslib, which will be used in the examples. This table is a copy of the 'sashelp.cars' dataset.
| 1 | DATA casuser.cars; SET sashelp.cars; RUN; |
This example generates a simple one-way frequency table for the 'Type' variable from the 'cars' table. This is the most basic use of the crossTab action.
| 1 | |
| 2 | PROC CAS; |
| 3 | SIMPLE.crossTab / TABLE={name='cars', caslib='casuser'} row='Type'; |
| 4 | |
| 5 | RUN; |
| 6 |
This example performs a two-way tabulation between the 'Type' and 'Origin' variables. It uses the 'MSRP' column as a weighting factor, meaning the frequency counts will be the sum of MSRP for each cell. It also requests chi-square statistics to test for independence between 'Type' and 'Origin'.
| 1 | |
| 2 | PROC CAS; |
| 3 | SIMPLE.crossTab / TABLE={name='cars', caslib='casuser'} row='Type' col='Origin' weight='MSRP' chiSq=true; |
| 4 | |
| 5 | RUN; |
| 6 |
This example computes a two-way frequency table for 'Type' and 'Origin' and requests various measures of association to quantify the strength of the relationship between these two categorical variables.
| 1 | |
| 2 | PROC CAS; |
| 3 | SIMPLE.crossTab / TABLE={name='cars', caslib='casuser'} row='Type' col='Origin' association=true; |
| 4 | |
| 5 | RUN; |
| 6 |
A large retail chain wants to optimize its supply chain by analyzing sales performance. Instead of a simple transaction count, they need to sum the total 'MSRP' (Market Suggeste...
An industrial manufacturing plant monitors engine temperatures via IoT sensors. The data is continuous, but engineers need to categorize temperatures into 5 distinct 'bins' (ran...
In a clinical drug trial, some patients dropped out, resulting in missing values for the 'SideEffects' variable. The researchers must include these missing values in the analysi...