Dear Statalists,

Hope all is well.

I am dealing with the contract data with specific contract start and end years as shown below:


Contract ID Contract Start Year Contract End Year
5 05aug1987 05nov1987
11 01sep1987 01sep1994
13 01aug1987 01aug1988
14 01aug1987 03feb1988
16 12sep1987 01jan1989
17 01sep1987 01mar1988
18 01sep1987 01sep1990
19 12sep1987 01oct1997
21 01oct1987 01oct1992
22 01oct1987 01oct1992
24 02sep1987 01oct1988
25 02sep1987 01oct1988
26 01sep1987 01apr1997
28 12sep1987 01nov1990
29 12sep1987 01nov1992
30 01sep1987 01sep1992
31 12aug1987 01mar1995
32 12aug1987 01mar1995
33 12aug1987 01mar1990
34 12aug1987 01mar1989
35 12aug1987 01mar1990
36 12aug1987 01mar1995

Could you please kindly let me know how to reshape this data into long format in Stata?

For example, for Contract ID "18", it should be presented as follows:


Contract ID Year
18 1987
18 1988
18 1989
18 1990

Many thanks in advance.

Best,
Cong