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 <>
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>=.


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:

*   For searches and help try:

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