Announcement

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

  • Identifying admissions 2 days either side of an event

    Hello,
    I have Dataset A where an event occurred. I have a tag for the event and an event date. In Dataset B, I would like to identify all the admissions two days either side of this event. So if the event occurred on the 5th of June, I would like to tag admissions from the 3rd of June to the 7th of June. Could you please help with how I might code this? thank you, Minda

  • #2
    Try rangejoin. Here is a similar Q&A on StackOverflow: https://stackoverflow.com/questions/...range-of-dates

    Comment


    • #3
      Consider a panel dataset where we have one unit that is treated.
      Code:
      u "http://econ.korea.ac.kr/~chirokhan/panelbook/data/basque-clean.dta", clear
      
      loc int_time = 1975
      
      g treated = cond(regionno==17 & year >= `int_time',1,0)
      
      labvars year gdpcap "Year" "ln(GDP per 100,000)"
      
      
      // I use labvars, but you don't need it.
      
      replace regionname = trim(regexr(regionname,"\(.+\) *",""))
      
      egen id = group(regionname), label(regionname) // makes a unique ID
      
      order id, b(year)
      
      *keep if year >= 1960
      drop if inlist(id,18) //12
      
      drop regionno
      xtset id year, y
      
      
      loc time: disp "`r(timevar)'"
      
      g rel = `time'-`int_time'
      
      keep if inrange(rel,-5,5)
      This is a panel dataset of 17 Spanish communities, where a unit was treated in 1975. To calculate event time, you simply subtract the time variable from the date of the first intervention.

      You don't give your datasets, so I can't comment on them, but it's likely a matter of merging the treatment variable/units to the dates you have for treatment, and following the code I've given here to suit your purposes.

      Comment

      Working...
      X