<?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: Transaction count &amp;amp; sum across days using arrays in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Transaction-count-amp-sum-across-days-using-arrays/m-p/321160#M70847</link>
    <description>&lt;P&gt;You didn't mention moving statistics in your initial post. Given your question,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/17429"&gt;@LaurieF&lt;/a&gt;&amp;nbsp;solution is correct.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a SAS note regarding using an array to calculating moving statistics.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that you cannot be missing dates in your series for an array method to work correctly, ie you need a record for every day.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/41/380.html" target="_blank"&gt;http://support.sas.com/kb/41/380.html&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 26 Dec 2016 11:16:59 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-12-26T11:16:59Z</dc:date>
    <item>
      <title>Transaction count &amp; sum across days using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transaction-count-amp-sum-across-days-using-arrays/m-p/321147#M70837</link>
      <description>Hi.I have data as below. I want to calculate sum &amp;amp; count of transactions across days based on condition "transaction amount between 0 to 4000" by cust and act.I have data from sep1st. 2011 to sep1st 2012&lt;BR /&gt;&lt;BR /&gt;Cust id actid trasdate transamt&lt;BR /&gt;100 1 9/30/2011 1500&lt;BR /&gt;100 1 11/4/2011 2000&lt;BR /&gt;100 1 11/4/2011 5000&lt;BR /&gt;100 1 11/4/2011 1000&lt;BR /&gt;100 1 11/5/2011 4000&lt;BR /&gt;100 1 11/5/2011 2500&lt;BR /&gt;&lt;BR /&gt;I want result as&lt;BR /&gt;&lt;BR /&gt;custd actid transdate sumtransamt cnt&lt;BR /&gt;100 1 9/30/2011 1500 1&lt;BR /&gt;100 1 11/4/2011 3000 3&lt;BR /&gt;100 1 11/5/2011 2500 1&lt;BR /&gt;&lt;BR /&gt;Appreciate ur help.&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Mon, 26 Dec 2016 09:00:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transaction-count-amp-sum-across-days-using-arrays/m-p/321147#M70837</guid>
      <dc:creator>SM3</dc:creator>
      <dc:date>2016-12-26T09:00:22Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction count &amp; sum across days using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transaction-count-amp-sum-across-days-using-arrays/m-p/321150#M70839</link>
      <description>&lt;P&gt;This is pretty close to what you want, I think:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data trancount;
infile cards;
attrib custid actid length=4
attrib transdate length=4 informat=mmddyy10. format=yymmdd10.;
attrib transamt length=6 format=comma14.;
input custid
      actid
      transdate
      transamt;
cards;
100 1 9/30/2011 1500
100 1 11/4/2011 2000
100 1 11/4/2011 5000
100 1 11/4/2011 1000
100 1 11/5/2011 4000
100 1 11/5/2011 2500
;
run;

proc sql;
create table result as
   select custid,
          actid,
          transdate,
          sum(transamt) as sumtransamt format=comma14.,
          count(*) as cnt length=4
     from trancount
    where 0 le transamt lt 4000 /* It appears you don't actually want 4,000 inclusive */
    group by custid,
             actid,
             transdate;
quit;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;There's so many ways to skin a cat with SAS; the second step could easily be replaced with a sort and a data step. But as long as it remains as simple as this, it should scale well.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Dec 2016 09:28:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transaction-count-amp-sum-across-days-using-arrays/m-p/321150#M70839</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2016-12-26T09:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction count &amp; sum across days using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transaction-count-amp-sum-across-days-using-arrays/m-p/321151#M70840</link>
      <description>Thanks Laurie.But I want to do this by using arrays. Can u help?</description>
      <pubDate>Mon, 26 Dec 2016 10:20:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transaction-count-amp-sum-across-days-using-arrays/m-p/321151#M70840</guid>
      <dc:creator>SM3</dc:creator>
      <dc:date>2016-12-26T10:20:57Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction count &amp; sum across days using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transaction-count-amp-sum-across-days-using-arrays/m-p/321152#M70841</link>
      <description>Array because the sum of transactions and count should be done by taking 5 days recurring window i,e sep1-5 then sept2-6 like that it goes on.</description>
      <pubDate>Mon, 26 Dec 2016 10:37:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transaction-count-amp-sum-across-days-using-arrays/m-p/321152#M70841</guid>
      <dc:creator>SM3</dc:creator>
      <dc:date>2016-12-26T10:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction count &amp; sum across days using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transaction-count-amp-sum-across-days-using-arrays/m-p/321160#M70847</link>
      <description>&lt;P&gt;You didn't mention moving statistics in your initial post. Given your question,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/17429"&gt;@LaurieF&lt;/a&gt;&amp;nbsp;solution is correct.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a SAS note regarding using an array to calculating moving statistics.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that you cannot be missing dates in your series for an array method to work correctly, ie you need a record for every day.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/41/380.html" target="_blank"&gt;http://support.sas.com/kb/41/380.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Dec 2016 11:16:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transaction-count-amp-sum-across-days-using-arrays/m-p/321160#M70847</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-12-26T11:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction count &amp; sum across days using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transaction-count-amp-sum-across-days-using-arrays/m-p/321179#M70857</link>
      <description>Yes Reeza, I agree LaurieF's solution is corrrct if we don't have moving statistics thing. Thanks</description>
      <pubDate>Mon, 26 Dec 2016 13:43:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transaction-count-amp-sum-across-days-using-arrays/m-p/321179#M70857</guid>
      <dc:creator>SM3</dc:creator>
      <dc:date>2016-12-26T13:43:32Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction count &amp; sum across days using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transaction-count-amp-sum-across-days-using-arrays/m-p/321212#M70877</link>
      <description>&lt;P&gt;Oops, ignore everything except my first paragraph.&amp;nbsp; You apparently want discrete (not rolling) 5-day windows, starting with 9/1/2011.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your WANT dataset has 3 transactions for 11/4, but only 1 for 11/5.&amp;nbsp; Is that consistent?&amp;nbsp; The resulting&amp;nbsp;CNT variable represents only qualifying transactions (&amp;lt;4000) for 9/30 and 11/5, but counts ALL transactions for 11/4.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRIKE&gt;You asked for an array solution, which I take means you want a data step approach.&amp;nbsp; However, while the array solution might be good for&amp;nbsp;rolling windows of fixed size, or for scanning over several amounts within each transaction,&amp;nbsp;I don't think it makes sense here.&amp;nbsp; Here's a data step program the generates the same SUMTRANSAMT value as you have, and generates a corresponding count of&lt;/STRIKE&gt; &lt;STRIKE&gt;eligible transaction&lt;/STRIKE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRIKE&gt;&lt;FONT color="#000080" face="Sasfont"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; want;&lt;/FONT&gt;&lt;/STRIKE&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRIKE&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;&amp;nbsp; set&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; trancount;&lt;/FONT&gt;&lt;/STRIKE&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRIKE&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;&amp;nbsp; by&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; custid actid transdate ;&lt;/FONT&gt;&lt;/STRIKE&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRIKE&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;&amp;nbsp; if&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; first.transdate &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Sasfont"&gt;do&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/STRIKE&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRIKE&gt;&lt;FONT face="Sasfont"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cnt=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Sasfont"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Sasfont"&gt;; sumtransamt=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Sasfont"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/STRIKE&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRIKE&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;&amp;nbsp; end&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/STRIKE&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRIKE&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;&amp;nbsp; if&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Sasfont"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Sasfont"&gt;&amp;lt;=transamt&amp;lt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Sasfont"&gt;4000&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Sasfont"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Sasfont"&gt;do&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/STRIKE&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRIKE&gt;&lt;FONT face="Sasfont"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cnt+&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Sasfont"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/STRIKE&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRIKE&gt;&lt;FONT face="Sasfont"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;sumtransamt+transamt;&lt;/FONT&gt;&lt;/STRIKE&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRIKE&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;&amp;nbsp; end&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/STRIKE&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRIKE&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;&amp;nbsp; if&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; last.transdate;&lt;/FONT&gt;&lt;/STRIKE&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRIKE&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;&amp;nbsp; drop&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; transamt;&lt;/FONT&gt;&lt;/STRIKE&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRIKE&gt;&lt;FONT color="#000080" face="Sasfont"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/STRIKE&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRIKE&gt;&amp;nbsp;&lt;/STRIKE&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRIKE&gt;I'm not saying it's&amp;nbsp;impossible to use arrays, but at the least, you'd have to know in advance the maximum number of transactions that might occur on a given date, so that you'd declare an array that is big enough to hold every transaction for the day.&amp;nbsp;&lt;/STRIKE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Dec 2016 22:56:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transaction-count-amp-sum-across-days-using-arrays/m-p/321212#M70877</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2016-12-26T22:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction count &amp; sum across days using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transaction-count-amp-sum-across-days-using-arrays/m-p/321214#M70879</link>
      <description>&lt;P&gt;Here's a solution that applies to 5-day date periods, using 01sep2011 as the reference date, but using arrays still seems sub-optimal.&amp;nbsp; It uses the same basic logic, and assumes your data are sorted by custid actid transdate:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Sasfont"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; need/&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;view&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;=need;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;&amp;nbsp; set&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; trancount;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Sasfont"&gt;&amp;nbsp;&amp;nbsp; date_group=floor((transdate-&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Sasfont"&gt;'01sep2011'd&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Sasfont"&gt;)/&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Sasfont"&gt;5&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Sasfont"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Sasfont"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Sasfont"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; want;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;&amp;nbsp; set&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; need;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;&amp;nbsp; by&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; custid actid date_group ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;&amp;nbsp; if&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; first.date_group &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Sasfont"&gt;do&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Sasfont"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cnt=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Sasfont"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Sasfont"&gt;; sumtransamt=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Sasfont"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;&amp;nbsp; end&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;&amp;nbsp; if&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Sasfont"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Sasfont"&gt;&amp;lt;=transamt&amp;lt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Sasfont"&gt;4000&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Sasfont"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Sasfont"&gt;do&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Sasfont"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cnt+&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Sasfont"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Sasfont"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;sumtransamt+transamt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;&amp;nbsp; end&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;&amp;nbsp; if&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; last.date_group;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;&amp;nbsp; drop&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; date_group transamt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Sasfont"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Dec 2016 23:13:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transaction-count-amp-sum-across-days-using-arrays/m-p/321214#M70879</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2016-12-26T23:13:09Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction count &amp; sum across days using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transaction-count-amp-sum-across-days-using-arrays/m-p/321225#M70886</link>
      <description>&lt;PRE&gt;

data trancount;
infile cards;
attrib custid actid length=4;
attrib transdate length=4 informat=mmddyy10. format=yymmdd10.;
attrib transamt length=6 format=comma14.;
input custid
      actid
      transdate
      transamt;
cards;
100 1 9/30/2011 1500
100 1 11/4/2011 2000
100 1 11/4/2011 5000
100 1 11/4/2011 1000
100 1 11/5/2011 4000
100 1 11/5/2011 2500
;
run;
data want;
n=0; sumtransamt =0;
 do until(last.transdate);
  set trancount;
  by custid actid transdate;
  if 0&lt;TRANSAMT&gt;&amp;lt;4000 then do;
   n+1; sumtransamt+transamt;
  end;
 end;
 drop transamt;
run;

&lt;/TRANSAMT&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Dec 2016 03:32:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transaction-count-amp-sum-across-days-using-arrays/m-p/321225#M70886</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-12-27T03:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction count &amp; sum across days using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transaction-count-amp-sum-across-days-using-arrays/m-p/321251#M70907</link>
      <description>&lt;P&gt;Guys I really appreciate all of ur help &amp;amp; i ll use ur suggestions and apply on my data. Want to clarify one thing regarding the data. The data i gave is just for one cust id and i have several such custid in my data with transaction date from 1sep 2011-30sep2012. Also there are instances where customers don't have transactions everyday. If there are multiple transactions in a &amp;nbsp;day i need to sum it up.First i need to identify transaction between 0-4k by using a rolling 5 day window ex: 1st spt to 5thsep, then 2nd sept to 6sep and so on and then i need to sum the transactions by cust id &amp;amp; acct id. Its little complex to assemble and thanks all for helping me out.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2016 06:24:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transaction-count-amp-sum-across-days-using-arrays/m-p/321251#M70907</guid>
      <dc:creator>SM3</dc:creator>
      <dc:date>2016-12-27T06:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction count &amp; sum across days using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transaction-count-amp-sum-across-days-using-arrays/m-p/321252#M70908</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/95975"&gt;@SM3&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Guys I really appreciate all of ur help &amp;amp; i ll use ur suggestions and apply on my data. Want to clarify one thing regarding the data. The data i gave is just for one cust id and i have several such custid in my data with transaction date from 1sep 2011-30sep2012. Also there are instances where customers don't have transactions everyday. If there are multiple transactions in a &amp;nbsp;day i need to sum it up.First i need to identify transaction between 0-4k by using a rolling 5 day window ex: 1st spt to 5thsep, then 2nd sept to 6sep and so on and then i need to sum the transactions by cust id &amp;amp; acct id. Its little complex to assemble and thanks all for helping me out.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This shouldn't be difficult and is within the first SAS programming course, break it down into smaller steps and you'll be fine. BY group processing will handle multiple ID and accounts without any difficulty. Please note, that I'm not trying to trivialize what you're trying to do, only trying to say&amp;nbsp;there isn't anything overly complex with what you've specified.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your steps appear out of order, but perhaps that's from what you're posting here. You're going to need to summarize per day BEFORE you calculate a rolling 5 day window, otherwise your filter won't be what you're expecting. You also need to define your 5 day definition&amp;nbsp;carefully. Is it always 5 days, or 5 business days or 5 transaction days? September is fine, but imagine any 5 day period that includes Dec 24th and 26th.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make sure that the data you provide shows the complexities of your data, but not overcomplicating it. Including a few ID/accounts is a good start.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2016 06:31:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transaction-count-amp-sum-across-days-using-arrays/m-p/321252#M70908</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-12-27T06:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction count &amp; sum across days using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transaction-count-amp-sum-across-days-using-arrays/m-p/321281#M70913</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/95975"&gt;@SM3&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;I know it's sometimes harder than if looks like from outside and I get it wrong more often than not when asking a question BUT: It's really worth if you take the time and provide fully representative sample data (a data step creating such data) and then show us how the expected result should look like. This avoids a lot of missunderstandings plus people giving their time to you don't waste their effort for the wrong problem.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2016 11:10:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transaction-count-amp-sum-across-days-using-arrays/m-p/321281#M70913</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-12-27T11:10:32Z</dc:date>
    </item>
  </channel>
</rss>

