Bookmark and Share

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   Nahla Betelmal <nahlaib@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: RE: what command to keep firms-years with multiple occurrence of only one type of events
Date   Wed, 2 Oct 2013 11:49:48 +0100

Thank you so much everyone. You gave me a great help.

Many thanks

Nahla

On 27 September 2013 16:39, Roberto Ferrer <refp16@gmail.com> wrote:
> Seems Robert beat me to that one.
>
> Bests,
> Roberto
>
> On Fri, Sep 27, 2013 at 4:37 PM, Roberto Ferrer <refp16@gmail.com> wrote:
>> If I understand correctly, the following should work. Just -sort-,
>> compare first event with last event and keep the event that interests
>> you.
>>
>> *-------------------------- begin example --------------------------------------
>> clear
>> input str2 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         1995      3
>> B         1996       2
>> B         1996       4
>> B         1996       3
>> end
>>
>> * what you want
>> sort firm year event
>> by firm year: keep if event[1] == event[_N] & event == 3
>>
>> *----------------------- end example -------------------------------------------
>>
>> On Fri, Sep 27, 2013 at 2:39 PM, Robert Picard <picard@netbox.com> wrote:
>>> 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 <jcanner1@jhmi.edu> 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: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nahla Betelmal
>>>> Sent: Friday, September 27, 2013 4:43 AM
>>>> To: statalist@hsphsun2.harvard.edu
>>>> 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/
>
> *
> *   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/


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