I would like to create a 5-by-5 grid of tabulate twoway
frequency count tables, like the following table.
Generating each sub-table is easy with nested foreach
loops, but the long list output is more difficult to interpret than a 5-by-5 grid (and has redundant entries -- it provides both halves of the symmetric matrix).
Is it possible to make a table like this in Stata? To be clear, I can figure out the LaTeX later, I am just interested in getting clear and concise console output.
Thanks! Here is some code that does the basics using the auto
data, but generates a list instead of a matrix. xtile
is from the egenmore
package
sysuse auto, clear
global vars price mpg headroom trunk weight
foreach x of global vars {
egen d_`x' = xtile(`x'), nquantiles(2)
}
* can make diagonal entries
tabulate d_price d_price
* can make off-diagonal entries
tabulate d_price d_mpg
* crude solution that generates list output with redundant entries
foreach x of global vars {
foreach y of global vars {
tabulate d_`x' d_`y'
}
}