Announcement

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

  • calculate number of trading days in event window

    Hello dear members of Statalist,

    I want calculate difference between the date (stock date) and the event date for my event window(11 days from -5 to +5). To do this, I created a variable, dif, that will count the number of days from the observation to the event date. Calculation in calendar days is easy (dif=date-event_date), but I need difference in trading days because the weekends and holidays are missing in the stock data and missing in the event window again. For example, my event is at 28.08.2014 (wednesday). If I calculate dif in calender days, the dif=-3, dif=-4, dif=+3, dif=+4 are missing in the event window. I would be happy if somebody can help me.

  • #2
    Check out business calendars. http://www.stata.com/help.cgi?business_calendars

    Comment


    • #3
      Originally posted by Nick Cox View Post
      I have Stata10. It is possible only in stata13, right?

      Comment


      • #4
        I it is fully explained in the UCLA website, for trading days, you should create datenumber varaible, the code is copied from the UCLA website
        sort company_id date
        by company_id: gen datenum=_n
        by company_id: gen target=datenum if date==event_date
        egen td=min(target), by(company_id)
        drop target
        gen dif=datenum-td
        Regards
        --------------------------------------------------
        Attaullah Shah, PhD.
        Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
        FinTechProfessor.com
        https://asdocx.com
        Check out my asdoc program, which sends outputs to MS Word.
        For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

        Comment

        Working...
        X