Search code examples
statacorrelation

Compact table with correlations in Stata


I would like to make a table with correlations between two groups of variables (that is, correlation between each variable in group 1 with each variable in group 2, correlation within variables in the same group I don't need) so that the final table has the first column with names of the first group's variables, and the first row second group's variables, and the table would show correlations between them.

corr is giving me a symmetrical matrix with all correlations, and it is not compact and nice for presenting results...

Is there some simple way, or command to do it, or what is the easiest way to get something like this?


Solution

  • cpcorr (SSC) allows display of a matrix with row variables and column variables chosen separately. You need to install it first and read the help to find out its syntax.

    Detailed discussion was given at http://www.statalist.org/forums/forum/general-stata-discussion/general/1310063-cpcorr-updated-on-ssc-module-for-rectangular-blocks-of-correlations

    Here is a simple example:

    . sysuse auto
    (1978 Automobile Data)
    
    . ssc inst cpcorr
    

    N.B. varying results depending on whether it has previously been installed

    . h cpcorr
    
    . cpcorr mpg price  \ weight length
    (obs=74)
    
            weight   length
      mpg  -0.8072  -0.7958
    price   0.5386   0.4318
    
    .