Good evening:

Below is a sample of data from my data set. The last column, NoBust, is how I want the variable to appear.
Year Country Country_2 AllBuster NoBust
1972 UK Cuba 0 0
1973 UK Cuba 0 1
1972 UK Cuba 1 2
1973 UK Cuba 0 0
1974 UK Cuba 0 1
1975 UK Cuba 0 2
1976 UK Cuba 0 3
1977 UK Cuba 0 4
I tried to do this in Stata, but I can't get it to appear in the table above. Instead, it appears as you see in the table below -- when the event, AllBuster, is 1, it resets to zero rather than continuing the series and starting zero after the event (as in my table above):
Year Country Country_2 AllBuster NoBust
1972 UK Cuba 0 0
1973 UK Cuba 0 1
1972 UK Cuba 1 0
1973 UK Cuba 0 2
1974 UK Cuba 0 3
1975 UK Cuba 0 4
1976 UK Cuba 0 5
1977 UK Cuba 0 6
This is the code that I came up with, but I can't for the life of me figure out how to get it to work the way I want.

Code:
by partnercode targetcode (year), sort: gen nobust = (allbuster0 == 1)
by partnercode targetcode (year): replace nobust = sum(nobust)
by partnercode targetcode nobust (year), sort: gen nobust0 = _n-1 if nobust >=0
drop nobust
Any help would be greatly appreciated!