Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: RE: what command to keep firms-years with multiple occurrence of only one type of events
From
Robert Picard <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: RE: what command to keep firms-years with multiple occurrence of only one type of events
Date
Fri, 27 Sep 2013 09:39:43 -0400
Another way:
bys Firm Year (Event): keep if (Event[1]==Event[_N]) & Event==3
Robert
On Fri, Sep 27, 2013 at 9:29 AM, Joe Canner <[email protected]> wrote:
> Nahla.
>
> If your Event variable is numeric, this should work:
>
> . bys Firm Year: egen mn=mean(Event)
> . bys Firm Year: egen sd=sd(Event)
> . keep if mn==3 & sd==0
>
> This is, admittedly, a little unconventional, but should be pretty efficient.
>
> Regards,
> Joe Canner
> Johns Hopkins University School of Medicine
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of Nahla Betelmal
> Sent: Friday, September 27, 2013 4:43 AM
> To: [email protected]
> Subject: st: what command to keep firms-years with multiple occurrence of only one type of events
>
> Dear Statalist members,
>
> It would be great if you can let me know what command I can use to keep firms-years with multiple occurrence of only one type of events in my data.
>
> I have firms-years-events data set. A firm can have multiple entries for the same year if it undertakes certain corporate events . I coded the events as 1,2,3, 4. For example the data looks like this
>
>
> Firm Year Event
> A 1994 2
> A 1994 3
> A 1994 3
> A 1995 1
> A 1995 3
> A 1996 2
> A 1996 4
> A 1996 3
> A 1997 3
> A 1997 3
> A 1998 1
> A 1998 1
> B
> ..
>
>
> I am only interested in studying firm-years where only event 3 was undertaken (i.e. keep both entries for year 1997 only). In other words, I want to drop firm years where there are a mix of events shown as multiple entries/observations ( years 1994, 1995, 1996) and multiple unique occurrence of event other than 3 (year 1998).
>
> I understand that I can do it on two stages, first drop firm-years with mix events, then second stage drop years with unique events other than 3.
>
> the problem that I don't know what command should I use to do the first stage ( drop firms-years with multiple entries of multiple events).
>
> Thank you in advance, I highly appreciate your kind help
>
> Nahla Betelmal
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/statalist-faq/
> * http://www.ats.ucla.edu/stat/stata/
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/statalist-faq/
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/