Announcement

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

  • How to remove all letters and leading numbers before year values

    I imported .xlsx file to stata, realizing that year values (int) looks like
    Code:
    01dec1981
    .
    Then I destring the variable using
    Code:
    destring year, gen(yr)
    before deleting the part before 1981. But destring value turns out 8005, which is weird to me.
    Is there any way to remove all the leading terms before 1981 so that my year value may look like just 1981?

    Thanks.
    Last edited by Chul-Kyoo Jung; 27 Dec 2021, 14:27.

  • #2
    Code:
    gen yr = year(year)
    you may also want to have a look in the help file in the date time function chapters.
    Code:
    help dates and times
    Last edited by Klaus Klausen; 27 Dec 2021, 14:43.

    Comment


    • #3
      Klaus Klausen thanks so much!

      Comment

      Working...
      X