Skip to main content

Stata: Cross Tabulations- Advanced

A brief introduction to Stata

What are Cross Tabulations?

Cross Tabulations, also known as contingency tables, are statistical analysis that examine the relationship between two (or more) variables. 

Note: For this example, General Social Survey 2016 data (located on "About Stata" tab) is used to produce the cross tabulation for respondent's health (health) and their confidence in medicine (conmedic). 

Cross Tabulations- Advanced: Point and Click

1. Go to Statistics > Summaries, tables, and tests > Frequency tables > Two-way table with measures of association

2. Under Row Variable: either (a) type the variable name or (b) select the variable name from the drop down menu.

3. Under Column Variable: either (a) type the variable name or (b) select the variable name from the drop down menu.

4. Within the box Test Statistics: select pearson's chi-squared

5. Within the box Cell Contents: select Within-column relative frequencies (column percents) and Within-row relative frequencies (row percents). 

6. Select "OK"


Additional Options: You can add and remove statistical analysis within Steps 4-5. Examples below: 

  • Row percentages: only check Within-row relative frequencies
  • Column percentages: only check Within-column relative frequencies
  • Chi-squared: only check pearson's chi-squared
  • Row percentages and chi-squared: check Within-row relative frequencies and pearson's chi-squared
  • Column percentages and chi-squared: check Within-column relative frequencies and pearson's chi-squared
  • Column and Row percentages: check Within-column relative frequencies and Within-row relative frequencies

Cross Tabulations- Advanced: Code

1. In the Command box type in the following code

tab variablename1 variablename2, row col chi

Example: tab health conmedic, row col chi

2. Hit Enter key


Additional Code Options: You can add and remove statistical analysis at the end of the code. Examples below. 

  • Row percentages only: tab variablename1 variablename2, row
  • Column percentages only: tab variablename1 variablename2, col
  • Chi-squared: tab variablename1 variablename2, chi
  • Row percentages and chi-squared: tab variablename1 variablename2, row chi
  • Column percentages and chi-squared: tab variablename1 variablename2, col chi
  • Row percentages and column percentagestab variablename1 variablename2, row col