Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: FW: argmax for -summaraize-


From   Jeph Herrin <[email protected]>
To   [email protected]
Subject   Re: st: FW: argmax for -summaraize-
Date   Mon, 24 Jul 2006 18:40:31 -0400

To avoid the rounding problem you can try

  gen cond= [if and/or in statments]
  bysort cond: egen xmax=max(x)

where "mycond" should probably include x>=.


hth,
Jeph



Feiveson, Alan H. (JSC-SK311) wrote:
Hello - Does anyone know an efficient way to identify the observation at
which a particular variable is minimum or maximum (subject to `if'
and/or `in') ?

Apparently -summarize- does not return this value. I see nothing in
-egen- nor  does "findit argmax" produce anything. I can program this
myself by looping through the observations but that is not efficient. In
particular one cannot gurantee that anything like

summ x
local xmax=r(max)
if x = `xmax' {
...

will work because of rounding. I also wish to avoid -preserve-,
-collapse-, etc

Al Feiveson



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