Announcement

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

  • Create a dummy variable for 6 months before and after a certain observation date

    Hello everyone!

    I have the following data format for stock observations with stock split events and would need some help:
    date: DCLRDT
    ....
    13mar1986
    14mar1986
    17mar1986
    18mar1986
    19mar1986
    20mar1986
    21mar1986
    24mar1986
    25mar1986
    ....
    19feb1986
    With date being the date of the stock observation and DCLRDT being the declaration date for the split on the split execution date (in this case the execution was 19mar1986). I would now like to create a dummy variable that is 1 if the current date is 6 months or less away from the date for the split execution(in this case 19mar1986) before and after the split. So for example if the date would be 14. April 1986 (after the split date) or 12. February 1986 (before the split date) I would have a 1 in the dummy variable.

    I do not really know how to do this, I tried to use loops but I am new to stata and could not find any further information on how to go through observations for only a specific range of months after and before a certain observation. I have millions of observations so sadly I cannot just pick out the split date manually and code around it.

    Thank you very much in advance!

  • #2
    What you showed is not the data as is present in Stata. We need to know exactly how you have your data in Stata, before we can answer your question. The devil is in the details with these kinds of problems. Look in the Statalist FAQ (black bar near the top of this page) for how to give examples of your data to us (look for dataex).
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment

    Working...
    X