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

RE: st: max value


From   "Ronnie Babigumira" <ronnie.babigumira@ios.nlh.no>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: max value
Date   Tue, 8 Apr 2003 16:14:44 +0200

Hi David, here is a sample of the data
+--------------------------------+
p1         p2         p3
--------------------------------
.0193647   .7684672   .2121681
.0110648   .0962676   .8926677
.00574   .8762589   .1180012
.0045997   .1808127   .8145875
.0024693   .3957042   .6018265
--------------------------------
.0067998   .3438436   .6493566
.0113164   .0771485   .9115351
.0123369    .133595    .854068
.0103629   .2671735   .7224636
.0085421   .1814262   .8100317
+--------------------------------+

To illustrate what I want, for the first two observations, I want my new
variable pred to be

pred
2 /* because p2 is the largest*/
3 /*because p3 is the largest*/
etc

About the largest value occuring in either values, it hasnt happened and I
dont anticpate that it will occur.

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of David Kantor
Sent: 8. april 2003 14:47
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: max value


Ronnie Wrote:

>Hi (stata8, win2k)
>I have 3 variables p1 p2 p3. I need to generate a new variable pred
>
>"pred" ==
>1 if p1 is the largest of the 3,
>2 if p2 is the largest
>and 3 if p3 is the largest
>[...]

This is not particularly difficult, but the problem, as stated is
ambiguous. What do you want to happen if the maximal value occurs in more
than one of the variables?

--David

David Kantor
Institute for Policy Studies
Johns Hopkins University
dkantor@jhu.edu
410-516-5404

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index