Announcement

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

  • how to create the start and end date for a year

    Dear statalist,

    This might be an easy question, but I didn't figure out how to do this. Say I have a set of years, 2010, 2014, 2015, 2019, 2020 etc, I want to create two dates, start date and end date, to account for the first day and last day of the year, e.g., 01jan2010 and 31dec2010, how to create these two variables? Thanks a lot for your help.

  • #2
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float year
    2010
    2014
    2015
    2019
    end
    
    gen first_day = mdy(1,1,year)
    gen last_day = mdy(12, 31, year)
    format *_day %td

    Comment


    • #3
      Thanks Clyde : )

      Comment

      Working...
      X