Hi list,
I am looking to generate a table that will allow easy comparison of changes in means and standard deviations across observed and imputed data for a list of variables.
Creating the first (left-hand) side of the table seems pretty straightforward:
tabstat `survey_items', stat(n mean sd) save
return list
matrix desc_stats = r(StatTotal)'
matlist desc_stats
putexcel set "${table_location}/Descriptive_statistics.xlsx", sheet("Sheet1") replace
putexcel A1= matrix(desc_stats), names overwritefmt
But I can't figure out how to generate a matrix with the same descriptive statistics for the imputed data. "misum" generates the statistics, but I am having difficulty making the matrix command work; the matrix is empty:
mi convert flong, clear
misum `survey_items'
matrix mi_desc_stats = r(StatTotal)'
matlist mi_desc_stats
This is what the last three commands output in the results window:
. misum `farmimp_items'
m=1/5 data
Variable | Mean SD min max N
-------------+-------------------------------------------------------
var1 | 2.719593 1.086147 .45611 5.109824 881
var2 | 2.949962 1.040069 .3450429 5.469518 881
var3 | 2.568165 1.140307 -.7103254 5.74613 881
var4 | 2.737817 .9577713 .6009374 4.83914 881
var5 | 3.478526 .7357405 1 5.017073 881
(etc. etc.)
. matrix mi_desc_stats = r(StatTotal)'
. matlist mi_desc_stats
| c1
-------------+-----------
r1 | .
Can anyone suggest what I might be doing wrong?
Best,
Ethan
I am looking to generate a table that will allow easy comparison of changes in means and standard deviations across observed and imputed data for a list of variables.
Creating the first (left-hand) side of the table seems pretty straightforward:
tabstat `survey_items', stat(n mean sd) save
return list
matrix desc_stats = r(StatTotal)'
matlist desc_stats
putexcel set "${table_location}/Descriptive_statistics.xlsx", sheet("Sheet1") replace
putexcel A1= matrix(desc_stats), names overwritefmt
But I can't figure out how to generate a matrix with the same descriptive statistics for the imputed data. "misum" generates the statistics, but I am having difficulty making the matrix command work; the matrix is empty:
mi convert flong, clear
misum `survey_items'
matrix mi_desc_stats = r(StatTotal)'
matlist mi_desc_stats
This is what the last three commands output in the results window:
. misum `farmimp_items'
m=1/5 data
Variable | Mean SD min max N
-------------+-------------------------------------------------------
var1 | 2.719593 1.086147 .45611 5.109824 881
var2 | 2.949962 1.040069 .3450429 5.469518 881
var3 | 2.568165 1.140307 -.7103254 5.74613 881
var4 | 2.737817 .9577713 .6009374 4.83914 881
var5 | 3.478526 .7357405 1 5.017073 881
(etc. etc.)
. matrix mi_desc_stats = r(StatTotal)'
. matlist mi_desc_stats
| c1
-------------+-----------
r1 | .
Can anyone suggest what I might be doing wrong?
Best,
Ethan
Comment