Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Generating a variable reporting the difference between values of another variable considered in different years (Panel dataset)

    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

  • #2
    You don't provide example data, so I'll just assume your data set has variables called unit_id identifying the housing unit, and year identifying the year. I'll also assume that both of those variables are numeric.

    Code:
    xtset unit_id year
    gen wanted = D.rr if t_change == 1
    See -help tsvarlist- for more information about time series operators.

    Comment


    • #3
      Yes, both your assumptions are right, sorry if I wasn't detailed enough! This worked perfectly, thanks so much!
      Aurora

      Comment

      Working...
      X