Store a cross tabulation in the worksheet

This macro stores a cross tabulation of two data columns into the worksheet. It creates a bar chart of observed and expected counts for each cell, and a bar chart of contribution to chi-square for each cell.

Download the Macro

Be sure that Minitab knows where to find your downloaded macro. Choose File > Options > General. Under Macro location browse to the location where you save macro files.

Important

If you use an older web browser, when you click the Download button, the file may open in Quicktime, which shares the .mac file extension with Minitab macros. To save the macro, right-click the Download button and choose Save target as.

Required Inputs

  • Two columns containing the tabled data
  • Storage location for the results. You must specify two more columns than the number of distinct values in the second tabled data column you list as an input.

Optional Inputs

GCNTS
Displays a bar chart of observed and expected counts.
GCHI
Displays a bar chart of contribution to chi-square.
STLAB C C
Required if you use any of the following subcommands to specify storage columns for the cell labels.
STOBS C
Use to specify a column (C) where the observed counts will be stored.
STEXP C
Use to specify a column (C) where the expected counts will be stored.
STCHI C
Use to specify a column (C) where the chi-square contribution will be stored.

Running the Macro

Suppose you want to store the cross tabulation of C1 and C2 in C11-C16 of the worksheet. You want to store the observed and expected counts in C6 and C7, respectively, and the cell labels in C4 and C5. To run the macro, choose View > Command Line/History and type:

%STXTAB C1 C2;
GCNTS;
GCHI;
STORE C11 - C16;
STLAB C4 C5;
STOBS C6;
STEXP C7.

Click Run.