<?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: dow loops in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80051#M23040</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;yea,the opening balance is actually the closing balance from the previous day which is a calculation of all the transaction within a given day&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 21 Jan 2013 00:04:29 GMT</pubDate>
    <dc:creator>Tal</dc:creator>
    <dc:date>2013-01-21T00:04:29Z</dc:date>
    <item>
      <title>dow loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80039#M23028</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 310px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD height="20" width="106"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;hi guys,&lt;/P&gt;&lt;P&gt;I need your help here please &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have this dataset (&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;mylib.active_suscribers_grouped)&lt;/SPAN&gt; below and i need to add two more fields to it (opening and closing balance ) grouped by calendar day.The closing balance =opening balance+Start+Restarted-Suspension-Termination and the opening balance is the closing balance from the previous day.The opening balance for 12/23/2012 is given to me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 310px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD height="20" width="106"&gt;Calendar_Day&lt;/TD&gt;&lt;TD width="99"&gt;Status&lt;/TD&gt;&lt;TD width="105"&gt;Sum&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20"&gt;12/23/2012&lt;/TD&gt;&lt;TD&gt;Terminated&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20"&gt;12/24/2012&lt;/TD&gt;&lt;TD&gt;Restarted&lt;/TD&gt;&lt;TD align="right"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20"&gt;12/24/2012&lt;/TD&gt;&lt;TD&gt;Start&lt;/TD&gt;&lt;TD align="right"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20"&gt;12/24/2012&lt;/TD&gt;&lt;TD&gt;Suspension&lt;/TD&gt;&lt;TD align="right"&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20"&gt;12/24/2012&lt;/TD&gt;&lt;TD&gt;Terminated&lt;/TD&gt;&lt;TD align="right"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20"&gt;12/25/2012&lt;/TD&gt;&lt;TD&gt;Restarted&lt;/TD&gt;&lt;TD align="right"&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20"&gt;12/25/2012&lt;/TD&gt;&lt;TD&gt;Terminated&lt;/TD&gt;&lt;TD align="right"&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so i need to get something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="563"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD height="20" width="106"&gt;Calendar_Day&lt;/TD&gt;&lt;TD width="99"&gt;Status&lt;/TD&gt;&lt;TD width="105"&gt;Sum&lt;/TD&gt;&lt;TD width="121"&gt;opening_balance&lt;/TD&gt;&lt;TD width="132"&gt;closing_balance&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20"&gt;12/23/2012&lt;/TD&gt;&lt;TD&gt;Terminated&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD align="right"&gt;5&lt;/TD&gt;&lt;TD align="right"&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20"&gt;12/24/2012&lt;/TD&gt;&lt;TD&gt;Restarted&lt;/TD&gt;&lt;TD align="right"&gt;2&lt;/TD&gt;&lt;TD align="right"&gt;4&lt;/TD&gt;&lt;TD align="right"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20"&gt;12/24/2012&lt;/TD&gt;&lt;TD&gt;Start&lt;/TD&gt;&lt;TD align="right"&gt;3&lt;/TD&gt;&lt;TD align="right"&gt;4&lt;/TD&gt;&lt;TD align="right"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20"&gt;12/24/2012&lt;/TD&gt;&lt;TD&gt;Suspension&lt;/TD&gt;&lt;TD align="right"&gt;4&lt;/TD&gt;&lt;TD align="right"&gt;4&lt;/TD&gt;&lt;TD align="right"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20"&gt;12/24/2012&lt;/TD&gt;&lt;TD&gt;Terminated&lt;/TD&gt;&lt;TD align="right"&gt;5&lt;/TD&gt;&lt;TD align="right"&gt;4&lt;/TD&gt;&lt;TD align="right"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20"&gt;12/25/2012&lt;/TD&gt;&lt;TD&gt;Restarted&lt;/TD&gt;&lt;TD align="right"&gt;6&lt;/TD&gt;&lt;TD align="right"&gt;0&lt;/TD&gt;&lt;TD align="right"&gt;-1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20"&gt;12/25/2012&lt;/TD&gt;&lt;TD&gt;Terminated&lt;/TD&gt;&lt;TD align="right"&gt;7&lt;/TD&gt;&lt;TD align="right"&gt;0&lt;/TD&gt;&lt;TD align="right"&gt;-1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and i am using this code below but i am not gettin what i am supposed to.Where i am wrong,please?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P class="ecxMsoNormal"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; mylib.active_suscribers_summed;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ecxMsoNormal"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; _n_ = &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;until&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;(last.calendar_day);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ecxMsoNormal"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; mylib.active_suscribers_grouped;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ecxMsoNormal"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; calendar_day;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ecxMsoNormal"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; _n_=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ecxMsoNormal"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;opening_balance=5&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ecxMsoNormal"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; status=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'Restarted'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; or status=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'Start'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; Closing_balance=sum(opening_balance,Sum);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ecxMsoNormal"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;else&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; Closing_balance=sum(opening_balance,-Sum);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ecxMsoNormal"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ecxMsoNormal"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ecxMsoNormal"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; _n_ ne &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ecxMsoNormal"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;opening_balance=lag(closing_balance);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ecxMsoNormal"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; status=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'Restarted'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; or status=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'Start'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; Closing_balance=sum(Opening_Balance,Sum);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ecxMsoNormal"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;else&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; Closing_balance=sum(Opening_balance,-Sum);&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ecxMsoNormal"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; _n_ = &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;to&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; _n_ ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ecxMsoNormal"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; mylib.active_suscribers_grouped;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ecxMsoNormal"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ecxMsoNormal"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ecxMsoNormal"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;run&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ecxMsoNormal"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ecxMsoNormal"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;the only thing i am getting right is the opening/closing balance for 12/23/2012 &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ecxMsoNormal"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ecxMsoNormal"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;Thanks&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Jan 2013 01:36:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80039#M23028</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2013-01-19T01:36:56Z</dc:date>
    </item>
    <item>
      <title>Re: dow loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80040#M23029</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm confused!&amp;nbsp; Your code doesn't match your desired results.&amp;nbsp; Is the following what you are trying to achieve?:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data active_suscribers_grouped;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat Calendar_Day mmddyy10.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format Calendar_Day mmddyy10.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat Status $10.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input Calendar_Day Status Sum;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;12/23/2012 Terminated 1&lt;/P&gt;&lt;P&gt;12/24/2012 Restarted 2&lt;/P&gt;&lt;P&gt;12/24/2012 Start 3&lt;/P&gt;&lt;P&gt;12/24/2012 Suspension 4&lt;/P&gt;&lt;P&gt;12/24/2012 Terminated 5&lt;/P&gt;&lt;P&gt;12/25/2012 Restarted 6&lt;/P&gt;&lt;P&gt;12/25/2012 Terminated 7&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data active_suscribers_summed;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set active_suscribers_grouped;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain opening_balance closing_balance;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_=1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; opening_balance=5;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if status='Restarted' or status='Start' then Closing_balance=sum(opening_balance,Sum);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else Closing_balance=sum(opening_balance,-Sum);&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; opening_balance=closing_balance;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if status='Restarted' or status='Start' then Closing_balance=sum(Opening_Balance,Sum);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else Closing_balance=sum(Opening_balance,-Sum);&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Jan 2013 03:45:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80040#M23029</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-01-19T03:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: dow loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80041#M23030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hey Arthur,&lt;/P&gt;&lt;P&gt;thanks for your response but no this is not what i need to achieve. I actually need to group the data by calendar day and find the closing and opening balance for each group not for&amp;nbsp; each single transaction as your code does .So for 12/24/2012&amp;nbsp; i have opening balance 5 and the closing balance should be 5+2+3-4-5=4.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Jan 2013 19:20:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80041#M23030</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2013-01-19T19:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: dow loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80042#M23031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="809722" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;: Then I probably still don't understand what you are looking for as my results don't match the results shown in your example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data active_suscribers_summed (drop=status);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set active_suscribers_grouped;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by Calendar_Day;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain opening_balance closing_balance;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first.Calendar_Day then opening_balance=5;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if status='Restarted' or status='Start' then Closing_balance=sum(opening_balance,Sum);&lt;/P&gt;&lt;P&gt;&amp;nbsp; else Closing_balance=sum(opening_balance,-Sum);&lt;/P&gt;&lt;P&gt;&amp;nbsp; if last.Calendar_Day then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Jan 2013 20:09:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80042#M23031</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-01-19T20:09:51Z</dc:date>
    </item>
    <item>
      <title>Re: dow loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80043#M23032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;yes Arthur,i need something as your code is&amp;nbsp; giving me except that the opening balance is the closing balance of the previous day.I tried&amp;nbsp; the lag function but not working for me.I am doing it wrong &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt; &lt;/P&gt;&lt;P&gt;Thanks a lot for your code &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Jan 2013 22:37:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80043#M23032</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2013-01-19T22:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: dow loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80044#M23033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;in other words opening_balance=5 is only for 12/23/2012 then the opening balance for next day would be whatever the closing one for the current day is and so on&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Jan 2013 22:51:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80044#M23033</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2013-01-19T22:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: dow loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80045#M23034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="809722" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;: My results still don't match your example, but I think that the following does what you describe:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data active_suscribers_summed (drop=status);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set active_suscribers_grouped;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by Calendar_Day;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain opening_balance closing_balance;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_ eq 1 then opening_balance=5;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if status='Restarted' or status='Start' then Closing_balance=sum(opening_balance,Sum);&lt;/P&gt;&lt;P&gt;&amp;nbsp; else Closing_balance=sum(opening_balance,-Sum);&lt;/P&gt;&lt;P&gt;&amp;nbsp; if last.Calendar_Day then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; opening_balance=closing_balance;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Jan 2013 23:37:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80045#M23034</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-01-19T23:37:49Z</dc:date>
    </item>
    <item>
      <title>Re: dow loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80046#M23035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;your code seems right but still dont know why it s not giving me the right values for the closing balance&lt;/P&gt;&lt;P&gt;this is the dataset:&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD height="20" style="border: 0px solid black;" width="106"&gt;Calendar_Day&lt;/TD&gt;&lt;TD style="border: 0px solid black;" width="99"&gt;Status&lt;/TD&gt;&lt;TD style="border: 0px solid black;" width="105"&gt;Sum&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border: 0px solid black;"&gt;12/23/2012&lt;/TD&gt;&lt;TD style="border: 0px solid black;"&gt;Terminated&lt;/TD&gt;&lt;TD align="right" style="border: 0px solid black;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border: 0px solid black;"&gt;12/24/2012&lt;/TD&gt;&lt;TD style="border: 0px solid black;"&gt;Restarted&lt;/TD&gt;&lt;TD align="right" style="border: 0px solid black;"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border: 0px solid black;"&gt;12/24/2012&lt;/TD&gt;&lt;TD style="border: 0px solid black;"&gt;Start&lt;/TD&gt;&lt;TD align="right" style="border: 0px solid black;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border: 0px solid black;"&gt;12/24/2012&lt;/TD&gt;&lt;TD style="border: 0px solid black;"&gt;Suspension&lt;/TD&gt;&lt;TD align="right" style="border: 0px solid black;"&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border: 0px solid black;"&gt;12/24/2012&lt;/TD&gt;&lt;TD style="border: 0px solid black;"&gt;Terminated&lt;/TD&gt;&lt;TD align="right" style="border: 0px solid black;"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border: 0px solid black;"&gt;12/25/2012&lt;/TD&gt;&lt;TD style="border: 0px solid black;"&gt;Restarted&lt;/TD&gt;&lt;TD align="right" style="border: 0px solid black;"&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border: 0px solid black;"&gt;12/25/2012&lt;/TD&gt;&lt;TD style="border: 0px solid black;"&gt;Terminated&lt;/TD&gt;&lt;TD align="right" style="border: 0px solid black;"&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt; and this is what i am supposed to get&lt;/P&gt;&lt;P&gt;date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; opening closing&lt;/P&gt;&lt;P&gt;12/23/2012&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;12/24/2012&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;12/25/2012&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -1&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 20 Jan 2013 19:29:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80046#M23035</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2013-01-20T19:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: dow loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80047#M23036</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;12/23/2012 opening balance=5,closing balance=5-1=4&lt;/P&gt;&lt;P&gt;12/24/2012 opening blance =4 closing balance=(4+2+3-4-5)=0&lt;/P&gt;&lt;P&gt;12/25/2012 opening balance=0,closing balance=0+6-7=-1 (sorry made&amp;nbsp; a typo in the previous post the top closing balance should read 4 not 1.&lt;/P&gt;&lt;P&gt;So the formulas seem right in the code but still dont get the right values&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 20 Jan 2013 19:35:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80047#M23036</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2013-01-20T19:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: dow loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80048#M23037</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think this might DOW what you need &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;PRE __default_attr="sql" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13587099833597404" jivemacro_uid="_13587099833597404"&gt;
&lt;P&gt;data raw ;&lt;/P&gt;
&lt;P&gt;input cal_d status : $15. sumv&amp;nbsp; ;&lt;/P&gt;
&lt;P&gt;attrib cal_d label='Calendar Day' format= date9. informat = mmddyy10. ;&lt;/P&gt;
&lt;P&gt;list;cards;&lt;/P&gt;
&lt;P&gt;12/23/2012&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Terminated&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;12/24/2012&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Restarted&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/P&gt;
&lt;P&gt;12/24/2012&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Start&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/P&gt;
&lt;P&gt;12/24/2012&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Suspension&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/P&gt;
&lt;P&gt;12/24/2012&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Terminated&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/P&gt;
&lt;P&gt;12/25/2012&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Restarted&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/P&gt;
&lt;P&gt;12/25/2012&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Terminated&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&lt;/P&gt;
&lt;P&gt; ; &lt;/P&gt;
&lt;P&gt;data d_bals ;&lt;/P&gt;
&lt;P&gt;retain open_bal 5 close_bal ;&lt;/P&gt;
&lt;P&gt;do n_trans =&amp;nbsp; 1 by 1 until( last.cal_d ) ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; set raw ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; by cal_d ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; if status = 'Terminated' then t_term = sumv ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; else&lt;/P&gt;
&lt;P&gt;&amp;nbsp; if status = 'Restarted'&amp;nbsp; then t_rest = sumv ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; else&lt;/P&gt;
&lt;P&gt;&amp;nbsp; if status = 'Suspension' then t_susp = sumv ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; else&lt;/P&gt;
&lt;P&gt;&amp;nbsp; if status = 'Start'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; then t_strt = sumv ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; else&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do; putlog 'please explain:' _all_ ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stop ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end ;&lt;/P&gt;
&lt;P&gt;end ;&lt;/P&gt;
&lt;P&gt;close_bal = Sum( open_bal, t_strt, t_rest, 0)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - sum( t_susp, t_term, 0 ) ;&lt;/P&gt;
&lt;P&gt; output ;&lt;/P&gt;
&lt;P&gt;open_bal = close_bal ;&lt;/P&gt;
&lt;P&gt;run ;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;It provides just one row for each cal date, like&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt; open_bal&amp;nbsp; close_bal&amp;nbsp; n_trans&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cal_d&amp;nbsp; status&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sumv&amp;nbsp; t_term&amp;nbsp; t_rest&amp;nbsp; t_susp&amp;nbsp; t_strt &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp; 23DEC2012&amp;nbsp; Terminated&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp; 24DEC2012&amp;nbsp; Terminated&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp; 25DEC2012&amp;nbsp; Terminated&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;of course, you can add a keep statement to reduce the results to just the columns youy want, but I left them in to let you see the "workings"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 20 Jan 2013 19:38:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80048#M23037</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2013-01-20T19:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: dow loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80049#M23038</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;yea it works.Thanks Peter &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt; .I still wonder why Arthur's code was not giving me the right closing balances when the code seemed so perfect.But thanks again to you two guys.Great job &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 20 Jan 2013 19:44:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80049#M23038</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2013-01-20T19:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: dow loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80050#M23039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="809722" __jive_macro_name="user" class="jive_macro jive_macro_user" href="https://communities.sas.com/"&gt;&lt;/A&gt;: Glad you have code now that does what you want.&amp;nbsp; My code didn't do what you were expecting because I didn't understand that opening_balance was supposed to be updated with each transaction.&amp;nbsp; As such, you really don't even need opening balance I think.&amp;nbsp; Try the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data active_suscribers_summed (drop=status);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set active_suscribers_grouped;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by Calendar_Day;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain closing_balance;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_ eq 1 then Closing_balance=5;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if status='Restarted' or status='Start' then Closing_balance=sum(Closing_balance,Sum);&lt;/P&gt;&lt;P&gt;&amp;nbsp; else Closing_balance=sum(Closing_balance,-Sum);&lt;/P&gt;&lt;P&gt;&amp;nbsp; if last.Calendar_Day then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 20 Jan 2013 20:39:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80050#M23039</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-01-20T20:39:59Z</dc:date>
    </item>
    <item>
      <title>Re: dow loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80051#M23040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;yea,the opening balance is actually the closing balance from the previous day which is a calculation of all the transaction within a given day&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jan 2013 00:04:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/dow-loops/m-p/80051#M23040</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2013-01-21T00:04:29Z</dc:date>
    </item>
  </channel>
</rss>

