<?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: find if the customer has another visit within 3 years in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/find-if-the-customer-has-another-visit-within-3-years/m-p/503160#M786</link>
    <description>&lt;P&gt;UNTESTED CODE&lt;/P&gt;
&lt;P&gt;Assumes your variable date is an actual SAS date value and not a character string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
    by store dept custid date;
run;
data want;
    set have;
    length newcolumn $ 3;
    prev_date=lag(date);
    prev_custid=lag(custid);
    prev_dept=lag(dept);
    prev_store=lag(store);
    if year(date)=2018 and upcase(visit)='NEW' and prev_custid=custid 
        and prev_dept=dept and prev_store=store then do;
         if intck('year',prev_date,date,'c')&amp;lt;3 then newcolumn='YES';
         else newcolumn='NO';
         output;
    end;
    drop prev:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 10 Oct 2018 17:29:47 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2018-10-10T17:29:47Z</dc:date>
    <item>
      <title>find if the customer has another visit within 3 years</title>
      <link>https://communities.sas.com/t5/New-SAS-User/find-if-the-customer-has-another-visit-within-3-years/m-p/503143#M782</link>
      <description>&lt;P&gt;I have a list of customers and i need to check &amp;nbsp;&lt;/P&gt;&lt;P&gt;Want&amp;nbsp;&lt;/P&gt;&lt;P&gt;if customers labeled 'NEW' in a department where seen within 3 year of their visit this year (2018)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Store&amp;nbsp; &amp;nbsp; Dept&amp;nbsp; &amp;nbsp; CustID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Visit&lt;BR /&gt;Macys&amp;nbsp; &amp;nbsp; Shoe&amp;nbsp; &amp;nbsp;1245&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;17-Feb-13&amp;nbsp; &amp;nbsp; NEW&lt;BR /&gt;Macys&amp;nbsp; &amp;nbsp; Shoe&amp;nbsp; &amp;nbsp;1245&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;25-Oct-15&amp;nbsp; &amp;nbsp;OLD&lt;BR /&gt;Macys&amp;nbsp; &amp;nbsp; Bags 1245 20-Jun-10 New&lt;BR /&gt;Macys Shoe 1245 4-Apr-18 NEW&lt;BR /&gt;Macys Bags 1245 2-Feb-11 OLD&lt;BR /&gt;Macys Makeup 1333 17-Aug-16 NEW&lt;BR /&gt;Macys Bags 1333 25-Sep-12 OLD&lt;BR /&gt;Macys Makeup 1333 21-Sep-18 New&lt;BR /&gt;Macys Shoe 1333 21-Sep-10 NEW&lt;BR /&gt;Macys Bags 1333 2-Feb-11 OLD&lt;BR /&gt;Nords Shoes 1444 17-Aug-09 NEW&lt;BR /&gt;Nords Shoes 1444 25-Sep-12 OLD&lt;BR /&gt;Nords Makeup 1444 21-Sep-18 New&lt;BR /&gt;Nords Bags 1555 21-Feb-10 OLD&lt;BR /&gt;Nords Shoe 1555 1-Oct-18 OLD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;want&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Store Dept CustID Date Visit Within 3 years&lt;BR /&gt;Macys Shoe 1245 4-Apr-18 NEW YES&lt;BR /&gt;Macys Makeup 1333 21-Sep-18 New YES&lt;BR /&gt;Nords Makeup 1444 21-Sep-18 New NO&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;a new column that tells me (yes or&amp;nbsp; no)&amp;nbsp; if a customer that is new this year was seen in the same dept within 3 years from there new visit this year&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 16:02:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/find-if-the-customer-has-another-visit-within-3-years/m-p/503143#M782</guid>
      <dc:creator>hk2013</dc:creator>
      <dc:date>2018-10-10T16:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: find if the customer has another visit within 3 years</title>
      <link>https://communities.sas.com/t5/New-SAS-User/find-if-the-customer-has-another-visit-within-3-years/m-p/503160#M786</link>
      <description>&lt;P&gt;UNTESTED CODE&lt;/P&gt;
&lt;P&gt;Assumes your variable date is an actual SAS date value and not a character string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
    by store dept custid date;
run;
data want;
    set have;
    length newcolumn $ 3;
    prev_date=lag(date);
    prev_custid=lag(custid);
    prev_dept=lag(dept);
    prev_store=lag(store);
    if year(date)=2018 and upcase(visit)='NEW' and prev_custid=custid 
        and prev_dept=dept and prev_store=store then do;
         if intck('year',prev_date,date,'c')&amp;lt;3 then newcolumn='YES';
         else newcolumn='NO';
         output;
    end;
    drop prev:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Oct 2018 17:29:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/find-if-the-customer-has-another-visit-within-3-years/m-p/503160#M786</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-10-10T17:29:47Z</dc:date>
    </item>
  </channel>
</rss>

