Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: egen rowmin but not value but variable name

From   Nick Cox <>
Subject   Re: st: egen rowmin but not value but variable name
Date   Mon, 13 Aug 2012 11:53:22 +0100

Dopey example. Which is minimum of price-gear_ratio in auto data?

sysuse auto, clear

gen which_min = "price"
gen min = price

qui foreach v of var mpg-gear_ratio {
      replace which_min = "`v'" if `v' < min
	replace min = `v' if `v' < min


On Mon, Aug 13, 2012 at 11:32 AM, Trelle Sven <> wrote:

> it might sound trivial but I was not able to find something in the egen
> or extended macro function help:
> I want to create a new variable that contains the variable name that
> holds the minimum value over several other variables per row i.e.
> something like the "egen x= rowmin(y z w)" command but the created
> variable should not contain the row minimum but the variable name that
> contains this minimum.
*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index