Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Generating a variable containing names of other variables


From   Thomas Speidel <[email protected]>
To   [email protected]
Subject   st: Generating a variable containing names of other variables
Date   Thu, 22 Jul 2004 11:54:58 -0600

I am trying to generate a new variable that contains the name of the variable where a certain expression is true.
For example consider the following:

jan feb mar apr may
0 200 195 203 119
175 193 220 107 0
98 226 0 0 0
...

I want to generate a new variable, say maxmth, that contains the name of the variable where the row maximum occurs.
In this case maxmth would look like this:

maxmth
apr
mar
feb
...

I tried something along this:
.egen maxmth=rmax(jan feb mar apr may)
.replace maxmth=_varname if maxmth==feb | maxmth==mar | maxmth==apr | maxmth==may

But I don't know how to refer to the variable name...

Thanks,
--
Thomas Speidel
Statistical Associate
Department of Oncology
Tom Baker Cancer Centre
1331 - 29th Street N.W.
Calgary, AB, T2N 4N4

Tel. (403) 944-3113
Email: [email protected]



This e-mail and any attachments may contain confidential and
privileged information. If you are not the intended recipient,
please notify the sender immediately by return e-mail, delete this
e-mail and destroy any copies. Any dissemination or use of this
information by a person other than the intended recipient is
unauthorized and may be illegal.
*
* 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