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

Re: st: maximum of a list of values


From   David Kantor <dkantor@jhu.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: maximum of a list of values
Date   Tue, 28 Jun 2005 15:38:56 -0400

At 11:01 AM 6/28/2005 -0700, Florence wrote:
also, one more question:

If I want to get the maximum of the first entry of a bunch of entries, then is there a way to do this in shorthand? i.e. suppose I want the maximum of x1[1,1], x2[1,1], x3[1,1], x4[1,1], x5[1,1], x6[1,1], x7[1,1] x8[1,1], then I thought it was possible to write: max(x1[1,1],...,x8[1,1]) but this isn't giving me all of the values in between.
thanks,
florence
*
max(x1[1,1],...,x8[1,1])
is not a legitimate expression; I get an error message when I present it (in Stata 8.2).

(But max(x1[1,1],.,x8[1,1]), with only one dot, is legitimate; the dot is a missing value, and is ignored.)

But did you mean that expression literally, or did you mean the fully-written-out...
max(x1[1,1], x2[1,1], x3[1,1], x4[1,1], x5[1,1], x6[1,1], x7[1,1], x8[1,1])
?

The latter ought to work out fine.

I'm not aware of any shorthand for this, though perhaps someone else can suggest something. If the problem is that you don't want an expression that uses a hard-coded set of matrix names, then you can set up some kind of loop to get your result.

HTH
-- 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/




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