Stata - Correlation Matrix

go back to the homepage
go back to the economics page
go back to the Stata page

The basic commands correlate or pwcorr are the easiest way to generate correlation matrices.  Many times, you can simply copy-and-paste the results or tables into Excel or MSWord.  If you want to manipulate their display format and other properties, you're more likely to use the estpost and esttab command as follows:

. ssc install estout 
. sysuse auto, clear
. local vars price mpg rep78 weight foreign
. estpost correlate `vars', matrix 
. esttab . using correlation.tex, unstack b(2) p(2) noobs nostar note("Note: P-values in parentheses") title(Correlation matrix) nonumber replace 
. !texify -p -c -b --run-viewer correlation.tex

The DO file at the top of the page walks through a few extra steps and explains some of that syntax.