Announcement

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

  • Make dummy variable using dates with format like 05jan2015 ( %td)

    Hi,

    I have a variabel named "salesday" with observations of different sales dates. The format is %td, and look like this 05jan2015 06jan2015 and so on.
    I want to make a dummy for specific dates that has a special sale that day. I know the dates. So lets say I want to make a dummy that is:

    generate special_sale = 0
    replace special_sale = 1 if salesday == "05jan2015"
    replace special_sale = 1 if salesday == "15jan2015"

    But when I try to replace the dummy with 1 for the date I get "type mismatch"
    If I try without the " " stata say that 05jan2015 is a invalid name.

    Can anyone help me with the correct way to do this in stata?

  • #2
    Try
    replace special_sale = 1 if salesday == td(05jan2015)

    Comment


    • #3
      Thank you, Eric!

      Comment

      Working...
      X