Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dummy variable in panel data

    Hi all,

    I've got monthly panel data on stock split announcements from the years 1999 to 2017 for 600 companies. All companies have a GICS code (industry code) and based on their six-digit GICS code they have got peers (companies who are in the same industry/have the same GICS-code).

    I want to make a dummy variable that takes the value of 1 when any of their peers have done a stock split announcement in the last 12 months and takes the value of 0 when none of their peers have done a stock split announcement. Do you have any idea how to obtain this dummy variable in STATA? Can you show me which kind of code to use?

    Example of my data

    T ; Company ; GICS ; Announcement
    1-1999; 1 ; 0
    2-1999; 1 ; 1
    ...

    Help will be greatly appreciated.



  • #2
    Thijs:
    welcome to this forum:
    Could it be:
    Code:
    bysort GISC: egen flag=total( Announcement)
    Last edited by Carlo Lazzaro; 13 Jun 2018, 11:33.
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      That doesn't give a dummy as a result...

      Comment


      • #4
        Hi Thijs,

        Please read the FAQ, specially regarding displaying a snippet of your dataset and using code delimiters.

        Out of the 2 industries you displayed, both are from the same GICS (and you said in your question that GICS is a 6 digit variable, while in the example you sent it is a 1 character variable). Based on the 2 observations dataset you shared with us, I created extra observation for hypothetical GICS without any annoucements and run Carlo's command, it seemed to work:

        Code:
        * Example generated by -dataex-. To install: ssc install dataex
        clear
        input float(T Company GICS Announcement)
        1 1999 1 0
        2 1999 1 1
        3 1999 2 0
        4 1999 2 0
        end
        
        bysort GICS: egen flag=total(Announcement)
        
        browse
        Both companies with GICS==1 were assigned flag==1 (because one of the had annoucement==1) and none of the 2 hypothetical GICS==2 were flagged - both had announcement==0.

        Please share a portion of your dataset (use dataex to do so) so that people can see the structure of your data and test solutions.

        Comment

        Working...
        X