Announcement

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

  • How to create a dummy variable for time series data

    So I'm trying to create a dummy variable for the global financial crisis of 2007-2008. My data runs from 1970-2019.
    so this is what i did;

    gen z=0
    replace z=1 if Year=2007
    replace z=1 if Year=2008

    long story short, this is wrong. I've tried absolutely everything. Would appreciate if someone could help!


  • #2
    Syntax for conditionals is two equal signs. Try:
    Code:
    replace z = 1 if Year == 2007 | Year == 2008

    Comment


    • #3
      This worked perfectly, May God bless you!

      Comment

      Working...
      X