<?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: Fetch customers list having one transaction per month in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Fetch-customers-list-having-atleast-one-transaction-per-month/m-p/874384#M345472</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let year = 2020;

proc sort
  data=have (where=(year(transaction_date) = &amp;amp;year.))
  out=sorted
;
by customer_id;
run;

data want;
set sorted;
by customer_id;
array m {12} _temporary_;
if first.customer_id then call missing(of m{*});
m{month(transaction_date)} = 1;
if last.customer_id and sum(of m{*}) = 12 then output;
keep customer_id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 08 May 2023 06:04:35 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-05-08T06:04:35Z</dc:date>
    <item>
      <title>Fetch customers list having  atleast one transaction per month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fetch-customers-list-having-atleast-one-transaction-per-month/m-p/874331#M345434</link>
      <description>&lt;P&gt;Hi All, I have a query below for which I am looking for a solution through sas and proc sql both.Could anyone please help here:&lt;/P&gt;&lt;P&gt;We have a sample data for a year with customers having transaction for different products. Customers may have multiple transaction in a month or no transaction in a month. We are require to fetch customers list who is having at least one transaction each month:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample Data:&lt;/P&gt;&lt;P&gt;Customer_ID Transaction_Date Transaction_Amount&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01/01/2020&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;100&lt;/P&gt;&lt;P&gt;909&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;02/01/2020&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;250&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;02/01/2020&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;45&lt;/P&gt;&lt;P&gt;900&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;03/02/2020&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 789&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 05/02/2020&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;950&lt;/P&gt;&lt;P&gt;:&lt;/P&gt;&lt;P&gt;:&lt;/P&gt;&lt;P&gt;:&lt;/P&gt;&lt;P&gt;and so on&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 May 2023 16:52:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fetch-customers-list-having-atleast-one-transaction-per-month/m-p/874331#M345434</guid>
      <dc:creator>Brad39</dc:creator>
      <dc:date>2023-05-07T16:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch customers list having one transaction per month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fetch-customers-list-having-atleast-one-transaction-per-month/m-p/874332#M345435</link>
      <description>&lt;P&gt;Your title and your text do not agree.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your title says "having one transaction per month"&lt;/P&gt;
&lt;P&gt;Your text says "having at least one transaction each month"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which is correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In either case, please show us the desired output from the sample data you provided.&lt;/P&gt;</description>
      <pubDate>Sun, 07 May 2023 14:28:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fetch-customers-list-having-atleast-one-transaction-per-month/m-p/874332#M345435</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-07T14:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch customers list having one transaction per month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fetch-customers-list-having-atleast-one-transaction-per-month/m-p/874340#M345437</link>
      <description>&lt;P&gt;I think you may&amp;nbsp; have to include a range of dates as well as in "at least one transaction each month in year 2020" or "at least one transaction each month between Jan 2018 and Mar 2023" or some such. Other wise we do not know which is the first or last month to be considered. Consider: if you expect a result that includes Jan 2018 and there is no data for that then none of your customers would qualify.&lt;/P&gt;</description>
      <pubDate>Sun, 07 May 2023 16:31:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fetch-customers-list-having-atleast-one-transaction-per-month/m-p/874340#M345437</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-05-07T16:31:44Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch customers list having one transaction per month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fetch-customers-list-having-atleast-one-transaction-per-month/m-p/874343#M345439</link>
      <description>condition is atleast one transaction per month. We just need to pull the customer ID's who are having atleast one transaction per month for an yearly data say 2020</description>
      <pubDate>Sun, 07 May 2023 16:53:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fetch-customers-list-having-atleast-one-transaction-per-month/m-p/874343#M345439</guid>
      <dc:creator>Brad39</dc:creator>
      <dc:date>2023-05-07T16:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch customers list having one transaction per month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fetch-customers-list-having-atleast-one-transaction-per-month/m-p/874344#M345440</link>
      <description>I am considering an yearly data for this query. From Jan 2020 to December 2020.</description>
      <pubDate>Sun, 07 May 2023 16:54:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fetch-customers-list-having-atleast-one-transaction-per-month/m-p/874344#M345440</guid>
      <dc:creator>Brad39</dc:creator>
      <dc:date>2023-05-07T16:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch customers list having one transaction per month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fetch-customers-list-having-atleast-one-transaction-per-month/m-p/874346#M345442</link>
      <description>&lt;P&gt;I think we would need a much larger sample data set than the one you provided, one that has several customers and transactions for an entire year for some of those customers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Repeating: please show us the desired output from the sample data you provided.&lt;/P&gt;</description>
      <pubDate>Sun, 07 May 2023 17:20:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fetch-customers-list-having-atleast-one-transaction-per-month/m-p/874346#M345442</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-07T17:20:32Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch customers list having one transaction per month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fetch-customers-list-having-atleast-one-transaction-per-month/m-p/874384#M345472</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let year = 2020;

proc sort
  data=have (where=(year(transaction_date) = &amp;amp;year.))
  out=sorted
;
by customer_id;
run;

data want;
set sorted;
by customer_id;
array m {12} _temporary_;
if first.customer_id then call missing(of m{*});
m{month(transaction_date)} = 1;
if last.customer_id and sum(of m{*}) = 12 then output;
keep customer_id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 May 2023 06:04:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fetch-customers-list-having-atleast-one-transaction-per-month/m-p/874384#M345472</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-05-08T06:04:35Z</dc:date>
    </item>
  </channel>
</rss>

