I have the following data:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str157 id str18 region float(t1 t2 ten_dur_monthly)
"AL1 1AJ-14--ORIENT CLOSE-ST ALBANS-ST ALBANS-HERTFORDSHIRE" "East" 606 691 85
"AL1 1AJ-18--ORIENT CLOSE-ST ALBANS-ST ALBANS-HERTFORDSHIRE" "East" 605 664 59
"AL1 1AJ-22--ORIENT CLOSE-ST ALBANS-ST ALBANS-HERTFORDSHIRE" "East" 617 706 89
"AL1 1AJ-26--ORIENT CLOSE-ST ALBANS-ST ALBANS-HERTFORDSHIRE" "East" 606 655 49
"AL1 1AJ-28--ORIENT CLOSE-ST ALBANS-ST ALBANS-HERTFORDSHIRE" "East" 614 701 87
end
format %tm t1
format %tm t2
To explain the context of the data, these are all different housing transactions, where:
- ID = Address
- region = the region of the UK where the house is located
- t1 = Date Bought
- t2 = Date Sold

The data ranges from 2000-M1 to 2019-M6.

My final aim is to have a Panel dataset where I have a month-year time variable (full range as observed in the data), and the average tenure duration for each region at each point in time. To do this, I was thinking that I need to create firstly the time variable and then, for each address, have a variable that indicates whether tenure has commenced or not, based on the values of t1. Then, we would continue counting the months until t2 is reached. At that point, the house is sold and thus tenure finishes.

I'm struggling with the code to do this. Do you have any suggestions?