Dear ,

I want to transform my dataset into panel dataset.

Currently my dataset looks like this (first 5 lines)

id start3 end3
1 12jul1983 01jan1985
2 01jan1983 31dec2013
3 01jan1985 31dec2013
4 01jan1989 01jan1999

I want it to transform to:

id start3. end3 year
1 12jul1977 01jan1985 1983
1 12jul1977 01jan1985 1984
1 12jul1977 01jan1985 1985
2 01jan1983 31dec2013 1983
2 01jan1983 31dec2013 1984
2 01jan1983 31dec2013 1985
....
2 01jan1983 31dec2013 2013

and so on with a new variable year (or equivalent time variable that adds up for each year an item is still being observed)

I have tried several ways using 'expand' in combination with 'bysort', _n commands, but I can't reach the desired result.

Can someone please advise me on this?

best wishes

Kutsal Yesilkagit