title: How to set 1 hour time window and then Do loop in SAS
body: <p>I've been searching for the answers for my question but couldn't find one so I post my question here.
  I have a huge data set. Before I ask my question, I'll explain how it looks like and what I want to do.</p>
  
  <pre><code>**ID**   **Website**  **Datetime**        **Googlevisit**
  A        Google       2014/06/01 16:50      1 
  A        Facebook     2014/06/01 17:40      1
  A        Yahoo        2014/06/01 18:00      0
  A        Facebook     2014/06/01 18:10      0
  A        Google       2014/06/01 19:00      1
  B        Amazon       
  B        Aol          
  B        Facebook     
  C        SouthWest    
  </code></pre>
  
  <p>ID is individual ID.
  Website is where each individual has browsed.
  Datetime is when each individual has browsed the website.</p>
  
  <p>What I want to do is I want to set an 1hour past interval from the current row time and then want to check if an individual has been to Google within 1hour or not. 
  For example, if an individual A from 19:00 to 18:00 searched Google at least once within 1hour interval, the new value in the new column is 1.
  Again, an individual A from 18:10 to 17:10 didn't search Google, so the value is 0. 
  Again, an individual A from 18:00 to 17:00 didn't search Google, so the value is 0. 
  Again, an individual A from 17:40 to 16:40 searched Google at least once within that interval, so the value is 1.</p>
  
  <p>I wasn't that good at coding but I tired hard to get the solutions for this.</p>
  
  <p>I tried this-></p>
  
  <pre><code>DATA A; SET A;
  if Website='Google' then Googlevisit=1;
  else Googlevisit=0;
  where Datetime between INTNX('second',Datetime,-3600) and Datetime;
  run;
  </code></pre>
  
  <p>also this too-></p>
  
  <pre><code>DATA A; SET A;
  if Datetime=&gt;INTNX('second',Datetime,-3600) and Datetime&lt;=Datetime then do;
  if Website='Google' then Googlevisit=1;
  else Googlevisit=0;
  end;
  run;
  </code></pre>
  
  <p>I thought these two codes were going to capture the 1hour interval but didn't.
  The output just shows that if the individual in a certain time visited google, the new value for that row becomes 1 or else, 0.
  It would be appreciated if someone help me out with this. I feel so desperate since I have been trying to solve this more than one week.</p>