Skip to content

Three way crosstabs

July 4, 2011

We have seen descriptive statistics and in this post, I am going to highlight how to do a cross-tabulation using more than two variables.

this is achievable by using the tabstat command

One can specify the statistics to show and with the help of bysort command, you can show cross-tabulations involving more than one variable.

Syntax:

tabstat variable[s], statistics(statistics) by(conditional variable)

Example 1:

tabstat age sat score heightin readnews, statistics(mean median sd var count range min max) by(gender)

Eaxmple 2:

bysort age:tab ed_level major- this examples first sorts the records by age and then cross-tabulates the dataset variables(ed_level and major)

Example 3:

bysort studentstatus: tab gender major, sum(sat) –This adds a fourth variable

Get data set here

From → Others

Leave a Comment

Leave a comment