Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# st: Reduced Correlation Matrix

 From "Meulemann Max" To "statalist@hsphsun2.harvard.edu" Subject st: Reduced Correlation Matrix Date Thu, 4 Oct 2012 13:05:34 +0000

```I´m having a problem creating a Correlation table of 6 variables from which I only want a reduced 3x3 correlation matrix to be exported to LaTeX.
I´ve been trying to find a stata program to do this directly without using any loop or something handmade, but it seems that there is no program that I can find.

I am using Stata 11.2 for Windows.

So let us say I have 6 variables from which I would get a 6x6 correlation matrix. For some reasons, I only like to have the correlation of 3 (row) variables with 3 (column) variables.

I picture it somewhat to be like this:
Var 4                      Var5                       Var6
Var1                   Cor(1,4)                Cor(1,5)                Cor(1,6)
Var2                   Cor(2,4)                Cor(2,5)                Cor(3,6)
Var3                   Cor(3,4)                Cor(3,5)                Cor(1,6)

added with standard deviation and asterixes for significance.

So far I have only come up with a solution to get at least the 3x3 matrix as a stata matrix, which would also work with the standard deviation.

mat corr=J(3,3,0)
forv i=1(1)3{
forv j=4(1)6{
quietly corr var`i' var`j'
mat c=r(C)
local cc=c[2,1]
mat corr[`i',`j'-3]=`cc'
}
}
mat list corr

Is anybody aware of a program or code that would do that, maybe also able to export it to LaTeX?

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```