Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Creating a dummy for each large firm in each fiscal year (foreach command)


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Creating a dummy for each large firm in each fiscal year (foreach command)
Date   Mon, 13 Jun 2011 08:26:36 +0100

If I understand this correctly, Daniel's code is equivalent to this,
for which the limits he referred to won't bite.

gen tag = fyear == 2008 & at > 100
bysort gvkey (tag) : gen largefirmdummy = tag[_N]

There's much more on this kind of thing in the Speaking Stata column
forthcoming in SJ 11(2) 2011.

No loops are needed at all.

Nick

On Sun, Jun 12, 2011 at 9:21 PM, daniel klein
<klein.daniel.81@googlemail.com> wrote:
> I do not think the first dummy (gvkeylarge) is needed here. One way to
> create the disired dummy (largefirmdummy) might be
>
> levelsof gvkey if (fyear==2008) & (at > 100) ,loc(keys) s(,)
> g byte largefirmdummy = inlist(gvkey, `keys')
>
> The -inlist()- function will not work if there are more than about 240
> large firms, though. If this is the case, you may have to create a
> loop over the elements of the local. Alternatively, you may also think
> about using -reshape- your data wide.
>
*
*   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index