Announcement

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

  • converting to date

    I have a variable "date" which consists of dates in the format _dd_mm_yyyy. I want it to be formatted as dates in proper dd-mm-yyyy . How can I edit the underscores?

  • #2
    Code:
    clear
    input str11 date
    "_01_01_2000"
    "_02_01_2000"
    "_03_01_2000"
    end
    
    gen date2 = date(date,"DMY")
    format date2 %td
    
    gen date3 = substr(date,2,.)
    replace date3 = subinstr(date3,"_","-",.)

    Comment

    Working...
    X