<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: DateDiff in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/DateDiff/m-p/704545#M215994</link>
    <description>&lt;P&gt;Try this (made a small edit - see comment):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname here '.';
proc import datafile="Data_Example.xlsx" out=have dbms=xlsx replace;
run;   
proc sort; 
     by customer_key; 
run;
data want;
     retain window cnt;
     set have;  
     by customer_key;
     if first.customer_key then do; 
          cnt=0; window=0; 
     end;
     if window + datediff &amp;lt;= 2 then do; 
          cnt=cnt+1; window = window + datediff;
     end;
     else do; 
          window=0; cnt = 1; /*changed cnt=0 to cnt=1*/
     end;
     if cnt &amp;gt;= 3 then flag='Y';
 run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 08 Dec 2020 20:51:23 GMT</pubDate>
    <dc:creator>vellad</dc:creator>
    <dc:date>2020-12-08T20:51:23Z</dc:date>
    <item>
      <title>DateDiff</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DateDiff/m-p/704514#M215987</link>
      <description>&lt;P&gt;Hello, hope everyone is safe.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this data set and I want to flag a Customer_Key that have 3 consecutive datediff of less 1.&amp;nbsp; What I'm trying to get is a customer that have a 3 or more transactions within a 2 day period.&amp;nbsp; Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2020 19:00:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DateDiff/m-p/704514#M215987</guid>
      <dc:creator>Eugenio211</dc:creator>
      <dc:date>2020-12-08T19:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: DateDiff</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DateDiff/m-p/704545#M215994</link>
      <description>&lt;P&gt;Try this (made a small edit - see comment):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname here '.';
proc import datafile="Data_Example.xlsx" out=have dbms=xlsx replace;
run;   
proc sort; 
     by customer_key; 
run;
data want;
     retain window cnt;
     set have;  
     by customer_key;
     if first.customer_key then do; 
          cnt=0; window=0; 
     end;
     if window + datediff &amp;lt;= 2 then do; 
          cnt=cnt+1; window = window + datediff;
     end;
     else do; 
          window=0; cnt = 1; /*changed cnt=0 to cnt=1*/
     end;
     if cnt &amp;gt;= 3 then flag='Y';
 run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2020 20:51:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DateDiff/m-p/704545#M215994</guid>
      <dc:creator>vellad</dc:creator>
      <dc:date>2020-12-08T20:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: DateDiff</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DateDiff/m-p/704810#M216092</link>
      <description>Thank you, It worked as I expected.</description>
      <pubDate>Wed, 09 Dec 2020 17:06:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DateDiff/m-p/704810#M216092</guid>
      <dc:creator>Eugenio211</dc:creator>
      <dc:date>2020-12-09T17:06:28Z</dc:date>
    </item>
  </channel>
</rss>

