Hello,

I have a panel dataset containing three vars: nation, year, and a variable called 'event' which is binary and = 1 when a specific type of event occurred in the nation. I'd like to create a 'time to event' index variable that resets by nation each time event = 1. I have done this as part of a traditional event study and it's pretty straight forward. But, in this dataset, there could be multiple events per nation, and I've not found any accessible resources that address that. My data look like this:
nation year host
ABW 1960 0
ABW 1961 0
ABW 1962 0
ABW 1963 1
ABW 1964 0
ABW 1965 0
ABW 1966 0
ABW 1967 0
ABW 1968 0
ABW 1969 1
ABW 1970 0
GBR 1960 0
GBR 1961 1
GBR 1962 0
GBR 1963 0
GBR 1964 0
GBR 1965 0
GBR 1966 0
GBR 1967 1
GBR 1968 0
GBR 1969 0
GBR 1970 0
USA
What I'm hoping to do is create a variable that looks like 't2e':
nation year host t2e
ABW 1960 0 -3
ABW 1961 0 -2
ABW 1962 0 -1
ABW 1963 1 0
ABW 1964 0 -5
ABW 1965 0 -4
ABW 1966 0 -3
ABW 1967 0 -2
ABW 1968 0 -1
ABW 1969 1 0
ABW 1970 0 .
GBR 1960 0 -1
GBR 1961 1 0
GBR 1962 0 -5
GBR 1963 0 -4
GBR 1964 0 -3
GBR 1965 0 -2
GBR 1966 0 -1
GBR 1967 1 0
GBR 1968 0 .
GBR 1969 0 .
GBR 1970 0 .
USA
Any help will be greatly appreciated.
-Ted