<?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: Creating a Rolling 12 Month Total in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373693#M89401</link>
    <description>&lt;P&gt;PROC EXPAND. The third example in the documentation illustrates the CONVERT statement.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Jul 2017 15:05:28 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-07-06T15:05:28Z</dc:date>
    <item>
      <title>Creating a Rolling 12 Month Total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373692#M89400</link>
      <description>&lt;P&gt;I have the following data attached and am trying to create the Rolling 12 Total column to the right based off of the date and Sum of Billing data to the left.&amp;nbsp; I did see an example using an array which I am not real familiar with using.&amp;nbsp; The total accumulates for only the last 12 months....Thanks for the help.&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>Thu, 06 Jul 2017 15:02:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373692#M89400</guid>
      <dc:creator>cbrotz</dc:creator>
      <dc:date>2017-07-06T15:02:07Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Rolling 12 Month Total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373693#M89401</link>
      <description>&lt;P&gt;PROC EXPAND. The third example in the documentation illustrates the CONVERT statement.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 15:05:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373693#M89401</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-06T15:05:28Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Rolling 12 Month Total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373700#M89405</link>
      <description>&lt;P&gt;I don't know what "documentation" you are referring to.&amp;nbsp; Can you give me a link?&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 15:43:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373700#M89405</guid>
      <dc:creator>cbrotz</dc:creator>
      <dc:date>2017-07-06T15:43:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Rolling 12 Month Total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373702#M89407</link>
      <description>&lt;P&gt;LMGTFY&amp;nbsp;: PROC EXPAND SAS DOCUMENTATION&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://documentation.sas.com/?docsetId=etsug&amp;amp;docsetTarget=etsug_expand_examples04.htm&amp;amp;docsetVersion=14.2&amp;amp;locale=en" target="_blank"&gt;http://documentation.sas.com/?docsetId=etsug&amp;amp;docsetTarget=etsug_expand_examples04.htm&amp;amp;docsetVersion=14.2&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need more information, try a user written paper from LexJansen.com. In general, you'll find many papers on any topic at LexJansen.com.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings10/093-2010.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings10/093-2010.pdf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 15:47:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373702#M89407</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-06T15:47:20Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Rolling 12 Month Total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373721#M89409</link>
      <description>&lt;P&gt;You can alway use the by-row processing and some lag functions. &amp;nbsp;I would take a look at your values of ROLLING 12 TOTAL in your attachment because I'm getting a different rolling 12 month value starting at 201403 than what is in the file, unless I'm misunderstanding the calculation of ROLLING 12 TOTAL. &amp;nbsp;The following code will give you a rolling 12-month sum of the BILLINGS values:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data input;
	format Date $6. Billings best8.;
	input Date Billings ;
	datalines;
201301 354.4
201302 94
201303 48.03
201304 119
201305 261.94
201306 359.22
201307 146
201308 198.45
201309 143.25
201310 65.27
201311 292.7
201312 71
201401 170.22
201403 205.4
201404 652.5
201405 18.52
201406 64.2
201408 88.2
201409 104.2
201410 79.5
201411 952.2
201412 106
;
run;

proc sort data=input;
	by Date;
run;

data output (keep=Date Billings Rolling_12);
set input;
	by Date;

retain x1-x11 Rolling_12;
x1 =lag1(Billings);
x2 =lag2(Billings);
x3 =lag3(Billings);
x4 =lag4(Billings);
x5 =lag5(Billings);
x6 =lag6(Billings);
x7 =lag7(Billings);
x8 =lag8(Billings);
x9 =lag9(Billings);
x10=lag10(Billings);
x11=lag11(Billings);

If _N_ = 1 then Rolling_12 = Billings;
	Else if _N_ &amp;lt; 12 then Rolling_12 + Billings;
	Else Rolling_12 = sum(Billings,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11);
run;

proc print data=output noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Jul 2017 17:13:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373721#M89409</guid>
      <dc:creator>dcruik</dc:creator>
      <dc:date>2017-07-06T17:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Rolling 12 Month Total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373723#M89411</link>
      <description>&lt;P&gt;Yes this is what I was looking for.&amp;nbsp; I did not know you could "lag" that many times.&amp;nbsp; Yes the numbers were given to me to match up to and they could be calculated incorrectly.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 17:35:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373723#M89411</guid>
      <dc:creator>cbrotz</dc:creator>
      <dc:date>2017-07-06T17:35:23Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Rolling 12 Month Total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373775#M89421</link>
      <description>&lt;P&gt;Proc expand is much shorter and easier to implement. And will handle BY group processing. Arrays also see simpler to me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're in search of an exact answer you can also search on here. For example here's one I answered last year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/Generating-rolling-12-month-totals-for-multiple-industry-codes/td-p/293717" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/Generating-rolling-12-month-totals-for-multiple-industry-codes/td-p/293717&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/112131"&gt;@cbrotz&lt;/a&gt;&amp;nbsp;please note that accepting your own solution is not correct. You should have accepted the solution that was posted by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/40360"&gt;@dcruik&lt;/a&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 20:28:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373775#M89421</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-06T20:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Rolling 12 Month Total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373785#M89423</link>
      <description>&lt;P&gt;&lt;SPAN style="font-family: &amp;quot;Calibri&amp;quot;,sans-serif; font-size: 11pt;"&gt;&lt;FONT color="#000000"&gt;Hi Reeza,&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: &amp;quot;Calibri&amp;quot;,sans-serif; font-size: 11pt;"&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: &amp;quot;Calibri&amp;quot;,sans-serif; font-size: 11pt;"&gt;&lt;FONT color="#000000"&gt;I am sorry I am just not following this code. &amp;nbsp;I modified it to use my sorted data set. Below.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: &amp;quot;Calibri&amp;quot;,sans-serif; font-size: 11pt;"&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: navy; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;PROC&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;SPAN style="background: white; color: navy; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;SORT&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;DATA&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;=WORK.SUMMARY_RET_DATA;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;BY&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt; GROUP_STATUS FCST_PROD_GRP YYYYMM;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: navy; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;data&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt; ret_avg12;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt; work.summary_ret_data;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt; group_status fcst_prod_grp yyyymm;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt; values(&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;12&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;_temporary_&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt; first.fcst_prod_grp &lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;then&lt;/SPAN&gt; &lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;call&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt; missing(of values(*));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;count=&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;count+&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;values(mod(count, &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;12&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;)+&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;) = open;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt; count&amp;gt;=&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;12&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt; average=mean(of values(*));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt; average &lt;/SPAN&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;dollar12.2&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: navy; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;run&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;This is my output….obviously I am not doing something right….&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 11pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="Times New Roman" size="3"&gt;&lt;IMG width="851" height="639" border="0" /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: &amp;quot;Calibri&amp;quot;,sans-serif; font-size: 11pt;"&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 22:08:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373785#M89423</guid>
      <dc:creator>cbrotz</dc:creator>
      <dc:date>2017-07-06T22:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Rolling 12 Month Total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373786#M89424</link>
      <description>Oh sorry I did not know how to delete and change the solution...</description>
      <pubDate>Thu, 06 Jul 2017 22:09:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373786#M89424</guid>
      <dc:creator>cbrotz</dc:creator>
      <dc:date>2017-07-06T22:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Rolling 12 Month Total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373789#M89425</link>
      <description>&lt;P&gt;1. Why did you delete all the comments? They explain what's happening and help you modify your code accordingly. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. You didn't replace the variable open. Note that there's a variable in your image with the name Open, that's your indicator to tell you something is incorrect. Go back to that step in the solution to see what you should be doing instead.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 22:48:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373789#M89425</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-06T22:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Rolling 12 Month Total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373791#M89426</link>
      <description>&lt;P&gt;This is the original code that I am using....I did not delete any comments.&amp;nbsp; I do not know what "open" means.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;sort&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;sashelp&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;stocks out&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;stocks&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token statement"&gt;by&lt;/SPAN&gt; stock &lt;SPAN class="token function"&gt;date&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; stocks_avg12&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; stocks&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token statement"&gt;by&lt;/SPAN&gt; stock&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="token statement"&gt;array&lt;/SPAN&gt; values&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;12&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; _temporary_&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;first&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;stock &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; do&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;call &lt;SPAN class="token function"&gt;missing&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;of values&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token function"&gt;count&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;0&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;end&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="token function"&gt;count&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;values&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;mod&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;count&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;12&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;open&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;count&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;12&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; average&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;mean&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;of values&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;format&lt;/SPAN&gt; average dollar12&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;expand&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;stocks_avg12 out&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;stocks_avg12_method2&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token statement"&gt;by&lt;/SPAN&gt; stock&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token keyword"&gt;id&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN class="token function"&gt;date&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;convert&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;open&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;average2 &lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt; transformout&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;movave &lt;SPAN class="token number"&gt;12&lt;/SPAN&gt; trimleft &lt;SPAN class="token number"&gt;11&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 22:55:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373791#M89426</guid>
      <dc:creator>cbrotz</dc:creator>
      <dc:date>2017-07-06T22:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Rolling 12 Month Total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373795#M89429</link>
      <description>&lt;P&gt;See the post right above the one you're using for the detailed comments. To save both of us some time here it is reposted. Run the EXAMPLE first to understand what's happening. I've already stated where the issue is - you're using the variable OPEN from the demo code rather than modifying it your data. This example uses SALES but it's the same concept.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are more comments than code in this solution.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create monthly sales data from January 2008 to December 2010 */
data test;
   do mo_period = '01jan2008'd to '31dec2010'd;
      sales = round(ranuni(1234567) * 1000, .01);
      mo_period = intnx('month', mo_period, 0, 'END');
      output;
   end;
   format mo_period monyy7. sales comma10.2;
run;

/* Specify the number of periods in the rolling sum and average */
%let roll_num = 12;

data new;
   set test;
/* Create array with specific number of elements. */
/* Passing _temporary_ arrays as arguments to functions is not supported */
/* until SAS 9.2. */
/* If the array is a _TEMPORARY_ array, the elements are automatically retained */
   array summed[&amp;amp;roll_num] _temporary_;

/* Alternatively, a non-temporary array can be used but it must be retained: */
/* array summed[&amp;amp;roll_num];*/
/* retain summed;*/

/* E represents the element of the array to assign a sales value. */
/* Increment it by one unless it is equal to &amp;amp;roll_num, at which point */
/* start over and assign it a value of 1. This causes the oldest period to */
/* be replaced by the newest period once &amp;amp;roll_num periods have been read. */
   if E = &amp;amp;roll_num then E = 1;
   else E + 1;

/* Assign value to proper element of the array */
   summed[E] = sales;

/* Start summing once &amp;amp;roll_num values have been read from the data set */
   if _N_ &amp;gt;= &amp;amp;roll_num then do;
      roll_sum = sum(of summed[*]);
      roll_avg = mean(of summed[*]);
   end;
   format roll_sum roll_avg comma10.2;
run;

proc print; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Jul 2017 23:05:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373795#M89429</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-06T23:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Rolling 12 Month Total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373796#M89430</link>
      <description>&lt;P&gt;Ok so I inserted my billing total in place of&amp;nbsp;the word "open" &amp;nbsp;and the code works but the output I am getting does not break and give me a totals after group_status and fcst_prod_grp and I am not looking for an average but a rolling total at the breaks - it needs to reset....&lt;/P&gt;&lt;P&gt;Do you know what I need to do to get it to give rolling totals&amp;nbsp;and break and reset after the by group?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Again I am sorry I really am just copying what you have here.&amp;nbsp; Perhaps once I get a working example I will understand it better.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;sort&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;sashelp&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;stocks out&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;stocks&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token statement"&gt;by&lt;/SPAN&gt; stock &lt;SPAN class="token function"&gt;date&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; stocks_avg12&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; stocks&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token statement"&gt;by&lt;/SPAN&gt; stock&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="token statement"&gt;array&lt;/SPAN&gt; values&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;12&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; _temporary_&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;first&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;stock &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; do&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;call &lt;SPAN class="token function"&gt;missing&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;of values&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token function"&gt;count&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;0&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;end&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="token function"&gt;count&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;values&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;mod&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;count&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;12&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; sum_of_billings&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;count&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;12&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; average&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;mean&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;of values&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;format&lt;/SPAN&gt; average dollar12&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;expand&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;stocks_avg12 out&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;stocks_avg12_method2&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token statement"&gt;by&lt;/SPAN&gt; stock&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token keyword"&gt;id&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN class="token function"&gt;date&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;convert&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;open&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;average2 &lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt; transformout&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;movave &lt;SPAN class="token number"&gt;12&lt;/SPAN&gt; trimleft &lt;SPAN class="token number"&gt;11&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&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>Thu, 06 Jul 2017 23:19:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373796#M89430</guid>
      <dc:creator>cbrotz</dc:creator>
      <dc:date>2017-07-06T23:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Rolling 12 Month Total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373797#M89431</link>
      <description>&lt;P&gt;I can't tell what's your code versus sample code here. Are you working off the sample or your own data now?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You've made &amp;nbsp;changes in some places but not others so I have no idea. Literally take every line of code (there's less than 12) comment it with what you think is happening based on text, and note what YOUR VARIABLES would be the equivalent and write your code underneath.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then comment out/delete the other code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 23:36:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373797#M89431</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-06T23:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Rolling 12 Month Total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373798#M89432</link>
      <description>&lt;P&gt;So I made a couple more changes below....zeroed out a field I am calling roll_tot at&amp;nbsp;each break&amp;nbsp;and then adding "sum_of_billings to that field to accumulate.&amp;nbsp; I changed "mean" to "sum".&amp;nbsp; I am not sure how that is going to affect the overall results but they look good from what I am seeing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ret_avg12;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; work.summary_ret_data;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; group_status fcst_prod_grp yyyymm;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;array&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; values(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;12&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;_temporary_&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; first.fcst_prod_grp &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; missing(of values(*));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;count=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;roll_tot=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;count+&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;roll_tot+sum_of_billings;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;values(mod(count, &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;12&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;)+&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;) = sum_of_billings;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; count&amp;gt;=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;12&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; roll_tot=sum(of values(*));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; roll_tot &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;dollar12.2&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 23:36:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373798#M89432</guid>
      <dc:creator>cbrotz</dc:creator>
      <dc:date>2017-07-06T23:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Rolling 12 Month Total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373801#M89433</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/112131"&gt;@cbrotz&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Perhaps once I get a working example I will understand it better.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Both examples posted are fully worked examples with BY groups/breaks exactly like yours with also exactly a 12 month lag. The only difference is the source data set and variables and replace MEAN with the word SUM.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 23:40:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373801#M89433</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-06T23:40:21Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Rolling 12 Month Total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373802#M89434</link>
      <description>&lt;P&gt;Reeza - thank you for your patience - this is not how I usually code so I had to work through it a bit but I think this part is SOLVED.&amp;nbsp; I would tag you but I do not see a way to do that. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp; Have a good evening.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 23:40:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373802#M89434</guid>
      <dc:creator>cbrotz</dc:creator>
      <dc:date>2017-07-06T23:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Rolling 12 Month Total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373804#M89435</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/112131"&gt;@cbrotz&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;So I made a couple more changes below....zeroed out a field I am calling roll_tot at&amp;nbsp;each break&amp;nbsp;and then adding "sum_of_billings to that field to accumulate.&amp;nbsp; I changed "mean" to "sum".&amp;nbsp; I am not sure how that is going to affect the overall results but they look good from what I am seeing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ret_avg12;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; work.summary_ret_data;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; group_status fcst_prod_grp yyyymm;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;array&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; values(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;12&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;_temporary_&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; first.fcst_prod_grp &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; missing(of values(*));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;count=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;roll_tot=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;count+&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;roll_tot+sum_of_billings;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt; *-&amp;gt; This line is wrong;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;values(mod(count, &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;12&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;)+&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;) = sum_of_billings;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; count&amp;gt;=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;12&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; roll_tot=sum(of values(*));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; roll_tot &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;dollar12.2&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 23:42:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373804#M89435</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-06T23:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Rolling 12 Month Total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373806#M89436</link>
      <description>Thank you!</description>
      <pubDate>Thu, 06 Jul 2017 23:45:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/373806#M89436</guid>
      <dc:creator>cbrotz</dc:creator>
      <dc:date>2017-07-06T23:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Rolling 12 Month Total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/375818#M90137</link>
      <description>&lt;P&gt;I think you can simply a great deal.&amp;nbsp; You don't need to keep separate queues for 1-month lag, 2-month lag, etc.&amp;nbsp; You really only need to keep a running total, adding the current record and subtracting the 12-month old record, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  rolling_12 + billings - coalesce(lag12(billings),0);
  window_size=min(12,_n_);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since the first 12 observations have lag12(billings)= missing, I should not attempt to subtract those values, so instead I subtract&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; coalesce(lag12(billings),0)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;COALESCE takes the left-most non-missing value from the list of argument, which means the zero for the first 12 obs.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 19:38:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Rolling-12-Month-Total/m-p/375818#M90137</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-07-13T19:38:35Z</dc:date>
    </item>
  </channel>
</rss>

