Announcement

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

  • ‘Or’ condition for time dummies

    Hi,

    I have a question about time dummies. Is it possible to have an ‘or’ condition for a time dummy? What I mean is for example: say my panel data is for the years 2000-2010, and I want to include a time dummy for whether two specific years (2005 and 2008) were significant or not. So D=1 if the given year is 2005 OR 2008, and D=0 otherwise. I am struggling to code this, help would be much appreciated!!

    Many thanks,
    Riaz

  • #2
    Maybe
    Code:
    generate byte y0508 = inlist(year, 2005, 2008) if !mi(year)

    Comment


    • #3
      Code:
      gen wanted = inlist(year, 2005, 2008)
      is the simplest way.

      A more literal translation of the wording into code, though somewhat longer to type is:

      Code:
      gen wanted = (year == 2005) | (year == 2008)
      Added: Crossed with #2, which handles missing values of year differently.

      Comment

      Working...
      X