Announcement

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

  • #16
    Indeed:

    date != daily date

    Stata dates = {date-time, daily date, weekly date, monthly date, quarterly date, half-yearly date, yearly date}

    Comment


    • #17
      Originally posted by Nick Cox View Post
      Dominik: You're replying to Clyde Schechter in #8. But #10 already pointed you to a solution, the numdate package from SSC.

      Code:
      clear
      input long date
      20141231
      20180316
      end
      
      format date %8.0f
      
      numdate daily newdate=date, pattern(YMD)
      extrdate month month=newdate
      
      list
      
      +------------------------------+
      | date newdate month |
      |------------------------------|
      1. | 20141231 31dec2014 12 |
      2. | 20180316 16mar2018 3 |
      +------------------------------+
      Hi Nick,

      How to extract month of birth in my case? the date format in my data is similar to the newdate variable in your example. I tried to use the following command but did not work. Thank you.
      Code:
      extrdate month month=newdate
      Error
      unknown function dofmonth()
      Data
      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input long birthdate
      7683
      4180
      7967
      6674
      4612
      8357
      8594
      7232
      7537
      9851
      7630
      5030
      5063
      8071
      8331
      8052
      9090
      6621
      3778
      3749
      end
      format %d birthdate

      Comment


      • #18
        I think the problem here is that you are using a legal but ancient and undocumented date display format. extrdate is not that flexible.

        Code:
        . format %td birthdate
        
        . 
        . extrdate month month=birthdate
        works for me with your data example. This is the first time that''s been flagged in 4 years since the command was posted, and there is an easy fix as above, so I am not tempted to fix the code.

        Comment


        • #19
          It works perfectly. Thank you.

          Comment

          Working...
          X