title: Better way to make/compare date ranges?
body: <p>I often have data that has a date1 and a date2. Date1 is the date we guess will have the event and date2 an event. I usually need to make 2 dummy variables where I increment date1 forwards a week and backwards then compare with the other 2. However I keep thinking there must be a better way to create a date range and then compare with a second date! </p>
  
  <p>Is there a way to do this in sas? Basically I want to take date1 and date2 and make this dataset and am wondering if I MUST create 2 additional variables (date1-7 days and date1+7days)
  Input datset:</p>
  
  <pre><code>DATE1         DATE2     
  
  
  
  10/23/2014  2/12/2015     
  
  
  2/12/2015   2/10/2015     
  </code></pre>
  
  <p>Current output:</p>
  
  <p>DATE1_wk_before         Date1_wk_after     Date2     In_range_indicator</p>
  
  <pre><code>10/16/2014               10/30/2014       2/12/2015       0 
  
  
  2/05/2015                 2/19/2015       2/10/2015       1
  </code></pre>
  
  <p>Where In_range_indicator = 1 if date is in the range and 0 if not in the range</p>
  
  <p>I want to know if I can do it just where I do something like
  In_range_indicator= 1 where Date2 is in range(week before date1 , week after date1) without creating 2 extra sets of data. It seems a waste of time.  </p>
  
  <p>I am LITERALLY adding 7 days and subtracting 7 days before and after and it seems a bad way to do this. </p>