Announcement

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

  • How to forward a value for dummy variable observed in one onto the next periods

    Hi everyone,

    I want to create a dummy variable for each individual in my panel, that takes a value 0 or 1 in period 3 (out of 10) and to forward the same value to all the following periods.
    example:
    id time dummy
    1 1 0
    1 2 0
    1 3 1
    1 4 1
    .
    .
    1 9 1
    1 10 1
    .


    Any suggestions?

    Thanks upfront
    Last edited by Marija Vasilevska; 27 Feb 2020, 10:06.

  • #2
    Code:
    bys id (time): replace dummy = dummy[_n-1] if time >3

    Comment


    • #3
      Thank you Andrew, it worked perfectly!

      Comment


      • #4
        This is an FAQ https://www.stata.com/support/faqs/d...issing-values/

        Comment


        • #5
          Thanks Nick

          Comment

          Working...
          X