Announcement

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

  • #16
    Originally posted by Gustavo Locatelli View Post
    Hi, unfortunately, the code didn't work in my case. Any idea why this happened?
    It happened because 01.01.2012 (range_start) falls outside the specified range, 19.4.2012-1.10.2019.

    Comment


    • #17
      Because 1/1/2012 does not fall between 19apr2012 and 1oct2019. That code comes from #4 and was intended to identify whether the range_start to range_end interval lies entirely within the date-open to date-close interval. Later in the thread, it became clear that what the O.P. wanted, but had unclearly stated, was to identify whether those intervals overlap. The thread later contains code that identifies overlap. If you, too, are looking for code to detect overlap, in terms of your variables, it would be:

      Code:
      clear*
      set obs 1
      gen range_start = td(1jan2012)
      gen range_end = td(31dec2012)
      gen date1 = td(19apr2012)
      gen date2 = td(1oct2019)
      format _all %td
      
      gen byte overlap = !(min(range_end, date2) < max(range_start, date1))
      
      list, noobs clean

      Comment


      • #18
        Hi, Clyde Schechter,

        Your code worked perfectly.

        Thank you very much.

        Comment

        Working...
        X