Hi all,

I'm trying to create a count variable for the number of years a factory has been in production. With the first year being counted as 0.


So:
Fac A 26 tons Dec 1941 0
Fac A 24 tons Jan 1942 1
Fac A 12 tons Feb 1942 1
Fac B 7 tons Dec 1943 0
Fac B 8 tons Jan 1944 1

I tried:

by fac: egen count dummy = count(Time)

But this doesn't work, particularly since my data is monthly.

Does anyone have any advice?