Announcement

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

  • Generate Date Range

    Dear All,

    I am struggling to generate a range of variables (time variables) to perform an analysis. A little bit of background I am working with time-series data performing analysis which strategy is to divide the dataset between periods of analysis (before/after a policy adoption). I have been trying to use the in-range function but I could not find a way to make work.


    In order to generate my time variable I apply the following code:

    //Generate time variable (monthly)
    generate time = m(1997m1) + _n-1
    format time %tm
    tsset time

    In order to assess my analysis, I would need to split the range

    before = from 1997m1 to 2011m4
    after = 2011m5 to 2019m12

    Could someone help me please!


  • #2
    Code:
    label define era 0 "2011m5 - 2019m12" 1 "1997m1 - 2011m4"
    gen byte era:era = inrange(time, tm(1997m1), tm(2011m4))
    Note: You are using m(...) to create monthly date constants in your code. This is old notation, superseded by tm(...). While the m(...) usage is still supported, at future date it may not be, so it might be best to update your usage.

    Comment

    Working...
    X