Dear Statalisters,
I have to create many tables of descriptive statistics, and have been asked to order the variables in the tables by their means.
Although it may seem an easy task, I was not able to find a solution.
I will illustrate my problem with auto.dta and just 4 variables:
clear
sysuse auto
su trunk weight length price
Variable | Obs Mean Std. Dev. Min Max
-------------+---------------------------------------------------------
trunk | 74 13.75676 4.277404 5 23
weight | 74 3019.459 777.1936 1760 4840
length | 74 187.9324 22.26634 142 233
price | 74 6165.257 2949.496 3291 15906
I would like to order the variables in, say, ascending order of their means, so as to get something like:
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------------------
trunk | 74 13.75676 4.277404 5 23
length | 74 187.9324 22.26634 142 233
weight | 74 3019.459 777.1936 1760 4840
price | 74 6165.257 2949.496 3291 15906
I could of course paste the table to Excel and order by "Mean", but I always try to do everything in Stata.
I could of course observe the means obtained and reorder the variables in my command:
su trunk length weight price
But such a solution is quite "homemade", I would very much prefer to be able to automatise it.
Thank you in advanced for your time and your help.
Andrés
I have to create many tables of descriptive statistics, and have been asked to order the variables in the tables by their means.
Although it may seem an easy task, I was not able to find a solution.
I will illustrate my problem with auto.dta and just 4 variables:
clear
sysuse auto
su trunk weight length price
Variable | Obs Mean Std. Dev. Min Max
-------------+---------------------------------------------------------
trunk | 74 13.75676 4.277404 5 23
weight | 74 3019.459 777.1936 1760 4840
length | 74 187.9324 22.26634 142 233
price | 74 6165.257 2949.496 3291 15906
I would like to order the variables in, say, ascending order of their means, so as to get something like:
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------------------
trunk | 74 13.75676 4.277404 5 23
length | 74 187.9324 22.26634 142 233
weight | 74 3019.459 777.1936 1760 4840
price | 74 6165.257 2949.496 3291 15906
I could of course paste the table to Excel and order by "Mean", but I always try to do everything in Stata.
I could of course observe the means obtained and reorder the variables in my command:
su trunk length weight price
But such a solution is quite "homemade", I would very much prefer to be able to automatise it.
Thank you in advanced for your time and your help.
Andrés
Comment