Announcement

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

  • Converting to month-yr

    Hello,

    I have tried using a few commands and haven't had luck--I think I am just confused. How do I turn dates that look like "01jan2020" into month-yr dates like "2020m1"? Data below. TIA--CJ

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double rmvl_entry_dt
    1.5900192e+12
    1.6153344e+12
    1.6153344e+12
    1.6153344e+12
    1.6153344e+12
    end
    format %tc rmvl_entry_dt

  • #2
    Is this the solution you were hoping for?
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear *
    input double rmvl_entry_dt
    1.5900192e+12
    1.6153344e+12
    1.6153344e+12
    1.6153344e+12
    1.6153344e+12
    end
    format %tc rmvl_entry_dt
    cls
    
    gen mnth = mofd(dofc(rmvl_entry_dt))
    
    br
    Last edited by Jared Greathouse; 30 Aug 2022, 08:05.

    Comment


    • #3
      I think Collin needs mofd(dofc())

      Comment


      • #4
        Indeed, I'd edited it before I refreshed the page Nick Cox.

        Luckily for me, I usually work with normal stuff like days, months, years and so on, but once you get into times and milliseconds, oh my Lord does Stata get complicated sometimes.

        Comment


        • #5
          Thank you both!

          Comment

          Working...
          X