Announcement

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

  • Get spells covering day

    I have two variables in %td format, one for begin spell and one for end spell. Spells can be paralle, and no spell spans multiple years.

    I want to open the dataset with only the spells that cover a cutoff day in a month, e.g. 15-1. If I would also give the year, I could filter with a condition like this (begin<=td(`mw') & end>=td(`mw')).

    But what if I want to filter only based on the month and day, but then load the spells of all years which cover the date. How can I do that?

  • #2
    I'm not sure I understand what you are looking for, but try this:
    Code:
    gen yr = year(begin)
    gen cutoff_date = mdy(1, 15, yr)
    keep if inrange(cutoff_date, begin, end)

    Comment

    Working...
    X