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

st: RE: Column and row maximums


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Column and row maximums
Date   Tue, 19 Nov 2002 14:27:58 -0000

[email protected]
> 
> I have a datasheet containing the following information (example)
> 
> A	B	C	D	E	F
> 1	2	3	4	5	6
> 2	8	5	4	9	6	
> 3	5	7	8	6	1
> 7	4	5	6	8	1
> 2	4	6	4	1	6
> 
> I need a command that will tell me what the highest number 
> in column E is
> (in this example 9) and also return the value in column B 
> for the same row
> (i.e. in this example 8).

What do you mean by "datasheet" or 
"column"? A data set and a variable? 
Or a matrix and a column thereof? 
I guess the former. In any event, please use 
standard Stata terminology when 
posting questions. 

You can have a single command that 
does both of these if you write it 
yourself. 

Otherwise 

. su E, meanonly 
. l B if E == r(max) 

Note that e.g. 

. findit row maximum 

points to -egen-, which 
would probably feature in 
whatever generalisation 
of this example is of interest 
to you. 

Also, in general, there may be
ties for maximum, meaning that 
this question may have multiple
answers. 

Nick 
[email protected] 

*
*   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