Announcement

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

  • How to convert a date into numerical for subtraction

    Dear members

    I have the following date: 12-Dec-15 and would like to convert it to numerical so I can great a dummy variable equal to one if the data is less than 12-Dec-15 and zero otherwise.

    What’s the right code to convert the data so I can use to create the dummy variable?

    thanks for your help

  • #2
    See help datetime and try


    Code:
    gen wanted = daily(whatever, "DMY", 2025)
    on the assumption that you have a string variable here.

    Comment


    • #3
      Thanks Nick for your response. The date is destringed .

      Comment


      • #4
        It's hard to know how 12-Dec-15 has passed through destring. You should give us a data example if #2 is not enough guidance.

        Comment


        • #5
          Two separate threads confused me. Sorry to be so dumb, but please don't do that.

          Comment


          • #6
            sorry Nick, the duplicated thread was due to an internet connection. My apology.

            Comment

            Working...
            X