Announcement

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

  • Imputation

    Hey guys,

    I work with panel data and I have the following problem.

    I've dummy variables from 2 years (2002/2007), but I need to create the dummy variable for the year 2004 with the condition that the identifier is the same. The new dummy of 2004 is 1, if the dummies of 2002 & 2007 are 1. I already added the missing years with "tsfill".

    How does the described imputation work?

    thank you in advance
    Ben







  • #2
    Benjamin:
    you may want to try:
    Code:
    bysort panelid: replace dummy=dummy[1] if dummy[1]==dummy[_N]
    Kind regards,
    Carlo
    (StataNow 19.0)

    Comment


    • #3
      Go with help variables. Not a very classy approach but it should work:
      Code:
      gen help2=1 if dummy==1 & inlist(year, 2002, 2007)
      sort id
      by id: egen help2=max(help1)
      replace dummy=1 if help2==1 & year==2004
      drop help1 help2

      Comment


      • #4
        Thanks guys, I really appreciate your help. I tried Carlos approach and it worked

        Comment

        Working...
        X