Announcement

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

  • Generate year month from a date variable

    Dear all,
    I am showing 2 observations from my 30000 observation data set below.

    Id is firm identifier
    sdate is the starting date of a firm that appears in this dataset
    edate is the starting date of a firm that appears in this dataset

    Code:
    clear
    input long id int(sdate edate)
    14471 19774 20697 
    14392 19774 21549 
    end
    format %d sdate
    format %d edate
    I want to generate the start year, month, and end year and month based on the above two variables. In stata the variables type is int.

    Could you please tell me how to do that ?


    Thanks,

    Rochelle

  • #2
    Code:
    help datetime
    Half the answer is in this post of yours: https://www.statalist.org/forums/for...-from-datetime

    Comment


    • #3
      Thank you Nick. I have not used date related function since then, so I forgot.

      Comment

      Working...
      X