|
以下程序主体用9楼sungmoo的代码,然后用estout程序包更加方便地获得格式化的输出(包括小数点位数、tab、rtf、excel等):
// check if -estout- is installed
capt which estout
if _rc ssc inst estout
// get data
sysuse auto.dta, clear
// collect correlation matrices
corr trunk weight length
matrix matpe = r(C)
spearman trunk weight length
matrix matsp = r(Rho)
matrix both = matpe
// combine the matrices
local I = rowsof(matpe)
forval i = 1/`I' {
local j1 = `i' + 1
forval j = `j1'/`I' {
matrix both[`i',`j'] = matsp[`i',`j']
}
}
// display and save the result in specified format, - help esttab -
mat l both
esttab matrix(both, fmt(3)) using example, nomtitle rtf
个人认为estout程序包的功能非常强大,值得大家好好看看。
|