Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Choosing the Minimum Value and Recording Variable Name
From
Erika Kociolek <[email protected]>
To
[email protected]
Subject
st: Choosing the Minimum Value and Recording Variable Name
Date
Wed, 3 Apr 2013 06:45:23 -0700
I am working with a dataset that looks like this:
id drug1 drug2 drug3 drug4 drug5 drug6
1 10 20 30 . . .
2 40 30 . 50 . .
I'd like write code that finds the minimum value of drug* and for each
observation, puts the name of the variable with this minimum value in
a new variable (let's call it minimum_var), i.e.:
id drug1 drug2 drug3 drug4 drug5 drug6 minimum_var
1 10 20 30 . . . drug1
2 40 30 . 50 . . drug2
I would prefer to do this without reshaping the data, and know that I
will need to account for ties.
Thank you in advance for your assistance!
Erika
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/