Hi everyone,

I think my question is quite simple but I wasn't able to solve it.
I have a panel dataset with information on 280 housing units over 24 time periods (years). For every unit and period I have the monthly rent of the unit (rr) and a dummy called t_change, which takes on value 1 if a new tenant enters the unit during that year.
I want Stata to generate a variable reporting the difference between the rent paid by tenants who just entered the unit (so, the rent paid in years when t_change = 1) and the rent paid for the same unit in the year before (by the old tenant).

What is the easiest way to do this?

Aurora