Announcement

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

  • Tag following 30 observations after specific criterion

    Hello,

    I have a dataset consisting of stocks and its daily price through a period of multiple years. I want to create a dummy variable. I have another variable ("X") being 1 for the day a stock split occured. Now I want that the 30 observations following the stock split should also be coded as 1. Therefore, every time the variable "X" is 1 I want to tag the following 30 observations (if these following 30 observations belong to the same stock). I want to do this as I want to analyze how the stock prices behave in the 30 days after a stock split.

    I appreciate any help!
    Last edited by Jana He; 19 Dec 2022, 09:17.

  • #2
    You should be able to do this easily with the community-contributed -rangestat- command (from SSC), with something like
    Code:
    rangestat (max) wanted = X , interval(date_var -30 0) by(stock_id)

    Comment

    Working...
    X