Hi everyone, I used the code from the post shown below and tried to get the correlation matrix. It works very well, thanks to the person who solved the question. The correlations between the same variables are not displayed as they are 1, because this is the requirement from the original post. However, I would like to get the correlations between the same variables to show that IT IS 1. From the code, I could not figure it out which line is supposed to be modified to displace the correlation 1. Any suggestions are apprieciated. Thank you.
Original post: https://www.statalist.org/forums/for...relation-table
Code:

Original post: https://www.statalist.org/forums/for...relation-table
Code:
Code:
sysuse auto, clear
matrix drop _all
** Set variables used in Summary and Correlation
local variables length weight displacement price
local labels `" "Length (in)" "Weight (lbs)" "Disp (ci)" "Price (USD)" "'
** Descriptive statistics
estpost summarize `variables'
matrix table = ( e(count) \ e(mean) \ e(sd) )
matrix rownames table = count mean sd
matrix list table
** Correlation matrix
correlate `variables'
matrix C = r(C)
local corr : rownames C
matrix table = ( table \ C )
matrix list table
estadd matrix table = table
local cells table[count](fmt(0) label(Count)) table[mean](fmt(2) label(Mean)) table[sd](fmt(2) label(Standard Deviation))
local collab
local drop
local i 0
foreach row of local corr {
local drop `drop' `row'
local cells `cells' table[`row']( fmt(4) drop(`drop') label((`++i')) )
local lbl : word `i' of `labels'
local collab `" `collab' `row' "(`i') `lbl'" "'
}
display "`cells'"
display `"`collab'"'
esttab using Report.rtf, ///
replace ///
noobs ///
nonumbers ///
compress ///
cells("`cells'") ///
coeflabels(`collab')

Comment