Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

R�p. : Re: st: Ranking of variables by means afterr -univar- or -summarize-


From   "Herve STOLOWY" <[email protected]>
To   <[email protected]>
Subject   R�p. : Re: st: Ranking of variables by means afterr -univar- or -summarize-
Date   Sat, 27 Jan 2007 19:12:18 +0100

Dear Joseph and Austin:

Thank you for your help. I found a solution using your suggestions with -collapse- and -reshape-.

Best regards

Herv�

***********************************************************
Professeur/Professor
HEC Paris
D�partement Comptabilit� Contr�le de gestion / Dept of Accounting and Management Control
1, rue de la Liberation
78351 - Jouy-en-Josas
France
Tel: +33 1 39 67 94 42 - Fax: +33 1 39 67 70 86
mail: stolowy at hec dot fr
web: http://studies.hec.fr/web/stolowy
>>> [email protected] 27/01/07 11:28 >>>
Herve Stolowy wrote:

I have about 50 variables. I get the mean with -univar- [redacted ]
or -summarize-.

univar var1 ... var50
summarize var1 ... var50

Is there a way to rank (descending order) the variables by there mean?

--------------------------------------------------------------------------------

Try the following.

Joseph Coveney


clear
set more off
set seed `=date("2007-01-27", "ymd")'
set obs 100
forvalues i = 1/50 {
    generate float var`i' = `i' + uniform()
}
*
* Begin here
*
collapse (mean) var*
generate byte row = 1
reshape long var, i(row) j(variable_nr)
egen rank = rank(var), field // track or field
*
* Done
*
gsort -var
list , noobs abbreviate(15)
exit

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index