> -----Original Message-----
> From: Jose Maria Pacheco de Souza [mailto:[email protected]]
> Sent: Friday, July 12, 2002 4:04 PM
> To: [email protected]
> Subject: st: return the name of the variable of greater rank
>
>
> Dear Statalisters:
>
> I have, say, variables var1 var2 var3 var4 var5 varcompare .
> I want to
> compare var1 var2 var3 var4 var5, to choose the one with the greatest
> rank. The _name_ of the vari with the greater rank should then be the
> string "value" of varcompare for each individual.
> Is there a command for this?
> Thanks,
> Jose Maria
gen str1 varcompare=""
gen valmax=max(var1 var2 var3 var4 var5)
foreach v in var1 var2 var3 var4 var5 {
replace varcompare=varcompare+" `v'" if `v'==valmax
}
This will put multiple varnames in the variable in case of ties. If you
don't want that,
take out the "varcompare+" part of the replace statement.
-Nick Winter
*
* 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/