--- Gabi Huiber wrote:
> How do you make Stata return the row number that corresponds to the
> maximum value in a given column, in Mata or Stata?
What about this example?
*---------------- begin example -------------
mata
x = 1 \ 2 \ 3 \ 2 \ 3
val = x[1,1]
rownum = 1
for(i = 2; i <= rows(x); i++){
if(x[i,1]==val){
rownum = rownum, i
}
if(x[i,1]>val) {
val = x[i,1]
rownum = i
}
}
val
rownum
end
*------------------ end example ------------------
Hope this helps,
Maarten
-----------------------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany
http://home.fsw.vu.nl/m.buis/
-----------------------------------------
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/