Announcement

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

  • Cumulatively counting dummy variable

    Hi, I have a simple time series with a dummy variable that is 0 on certain times and 1 on others I would like to create a new variable that would cumulatively track each "success" like this:

    time dummy counter
    1 0 0
    2 0 0
    3 1 1
    4 0 1
    5 1 2
    6 0 2
    7 0 2

    and so forth, thanks in advance for any help!

  • #2
    Code:
    sort time
    gen counter = sum(dummy)

    Comment

    Working...
    X