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: modifying egen to add a replace feature

From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: modifying egen to add a replace feature
Date   Thu, 19 Jul 2012 09:09:01 +0100

Not so. Writing a new -egen- function so that it takes a -replace-
option is not the issue here. -egen- will throw out the call if -y- is
an existing variable before the function code is even entered. The
issue is cloning -egen- to do the replacement.

As I've signalled elsewhere, I think  it is easiest just to -drop-
what you don't want and/or do a -replace- afterwards.


On Thu, Jul 19, 2012 at 8:13 AM, Maarten Buis <[email protected]> wrote:
> On Wed, Jul 18, 2012 at 5:00 PM, Pradipto Banerjee wrote:
>> Is it possible to rewrite or modify egen, or create an ado file, such that I can simply write like this:
>> bysort x: egen y = myfunc (y, a, b, ...), replace
> Yes, the logic behind the way -egen- works is that if you type -egen y
> = myfunc()-, -egen- will look for a file _gmyfunc.ado, which
> implements the function myfunc() and it also passes the option you
> have specified to that .ado file. So you can write your own -egen-
> functions. The easiest way to get started is to look at an existing
> similar function and addept that, e.g. look at -viewsource _gmean.ado.
*   For searches and help try:

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