Announcement

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

  • How to calculate the number of days (time period) between start and end years?

    I was wondering how to calculate the number of days between a start period of an event to the end period of an event.The start and periods are formatted in year-month-day (20000131 to 20021015). I need to calculate the difference in the number of days to measure how many days an event has taken place for survival analysis. Kindly let me know how to calculate the number of days. I searched in Statalist for any posts, but I could not find any. I attached a screenshot for reference.
    Click image for larger version

Name:	Screen Shot 2018-03-21 at 4.22.21 PM.png
Views:	1
Size:	223.5 KB
ID:	1435558

  • #2
    Read -help datetime-. Then convert your "date" variables, which are pretty useless in their current form, to Stata internal format date variables. (The easiest way to do this will be with the -numdate- program, by Nick Cox, available from SSC.) Then subtract the dates.

    Comment


    • #3
      Thank you.

      Comment

      Working...
      X