Hello
I'm trying to build a table in which the mean, SD, and correlations between a group of continuous variables are all displayed. I need the variable name, mean (1 decimal place), SD (1 decimal place), and correlation table (two decimal places, with stars to to denote .10, .05, and .01 significance).
I found a post from 2019 with this code, which I thought I would use as a base. I modified the 2019 code so that the count is no longer displayed
However, this code produces an empty table. Does anyone have suggestions for how to fix this code so it works in State 16, and also if it's feasible, how to add the asterisks for statistical significance? Thanks.
Chris
I'm trying to build a table in which the mean, SD, and correlations between a group of continuous variables are all displayed. I need the variable name, mean (1 decimal place), SD (1 decimal place), and correlation table (two decimal places, with stars to to denote .10, .05, and .01 significance).
I found a post from 2019 with this code, which I thought I would use as a base. I modified the 2019 code so that the count is no longer displayed
Code:
sysuse auto, clear matrix drop _all ** Set variables used in Summary and Correlation local variables length weight displacement price ** Descriptive statistics estpost summarize `variables' matrix table = ( e(mean) \ e(sd) ) matrix rownames table = mean sd matrix list table ** Correlation matrix correlate `variables' matrix C = r(C) local k = colsof(C) matrix C = C[1..`=`k'-1',.] local corr : rownames C matrix table = ( table \ C ) matrix list table estadd matrix table = table local cells table[table[mean](fmt(2) label(Mean)) table[sd](fmt(2) label(Standard Deviation)) local drop foreach row of local corr { local drop `drop' `row' local cells `cells' table[`row'](fmt(2) drop(`drop')) } display "`cells'" esttab using Report.rtf, /// replace /// noobs /// nonumbers /// compress /// cells("`cells'")
However, this code produces an empty table. Does anyone have suggestions for how to fix this code so it works in State 16, and also if it's feasible, how to add the asterisks for statistical significance? Thanks.
Chris
Comment