<?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: Running total, but in cycles with roll over in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Running-total-but-in-cycles-with-roll-over/m-p/164246#M31766</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That totally worked, thank you!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 05 Feb 2014 19:53:50 GMT</pubDate>
    <dc:creator>bailunrui</dc:creator>
    <dc:date>2014-02-05T19:53:50Z</dc:date>
    <item>
      <title>Running total, but in cycles with roll over</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-total-but-in-cycles-with-roll-over/m-p/164242#M31762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So, the data that I'm analyzing is set up in a strange way. For each person's device, there can only be 255 event numbers recorded before it rolls over, but this can happen several times. An event 0 is when the device is turned on. After a 255, there is usually a number greater than 0, indicating a roll over (unless by pure chance the device was turned off after exactly 255 cycles and turned back on again). Here is what my data looks like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" jive-data-cell="{&amp;quot;color&amp;quot;:&amp;quot;#000000&amp;quot;,&amp;quot;textAlign&amp;quot;:&amp;quot;left&amp;quot;,&amp;quot;padding&amp;quot;:&amp;quot;2&amp;quot;,&amp;quot;backgroundColor&amp;quot;:&amp;quot;transparent&amp;quot;,&amp;quot;fontFamily&amp;quot;:&amp;quot;arial,helvetica,sans-serif&amp;quot;}" jive-data-header="{&amp;quot;color&amp;quot;:&amp;quot;#FFFFFF&amp;quot;,&amp;quot;backgroundColor&amp;quot;:&amp;quot;#6690BC&amp;quot;,&amp;quot;textAlign&amp;quot;:&amp;quot;center&amp;quot;,&amp;quot;padding&amp;quot;:&amp;quot;2&amp;quot;,&amp;quot;fontFamily&amp;quot;:&amp;quot;arial,helvetica,sans-serif&amp;quot;}" style="border: 1px solid #000000; width: 25%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px; font-family: arial,helvetica,sans-serif;"&gt;Person&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px; font-family: arial,helvetica,sans-serif;"&gt;Event Number&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px; font-family: arial,helvetica,sans-serif;"&gt;Total I Want&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;0&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: #ffff99; font-family: arial,helvetica,sans-serif;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;75&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: #ffff99; font-family: arial,helvetica,sans-serif;"&gt;75&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;79&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: #ffff99; font-family: arial,helvetica,sans-serif;"&gt;79&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;150&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: #ffff99; font-family: arial,helvetica,sans-serif;"&gt;150&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;255&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: #ffff99; font-family: arial,helvetica,sans-serif;"&gt;255&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;4&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: #ffff99; font-family: arial,helvetica,sans-serif;"&gt;259&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;20&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: #ffff99; font-family: arial,helvetica,sans-serif;"&gt;275&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;80&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: #ffff99; font-family: arial,helvetica,sans-serif;"&gt;335&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;230&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: #ffff99; font-family: arial,helvetica,sans-serif;"&gt;485&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;255&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: #ffff99; font-family: arial,helvetica,sans-serif;"&gt;510&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;36&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: #ffff99; font-family: arial,helvetica,sans-serif;"&gt;546&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;B&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;0&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: #ffff99; font-family: arial,helvetica,sans-serif;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;B&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: transparent;"&gt;15&lt;/TD&gt;&lt;TD style="padding: 2px; color: #000000; text-align: left; background-color: #ffff99; font-family: arial,helvetica,sans-serif;"&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The algorithm to do this is just eluding me. I've tried retaining and lagging and all I'm getting is nowhere. I was able to code through the first roll over, but when it hit another one, my code failed. When I try to think recursively, my mind turns to mush.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone help me? Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lauren&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Corrected addition mistake. Message was edited by: Lauren Parlett&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Feb 2014 18:18:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-total-but-in-cycles-with-roll-over/m-p/164242#M31762</guid>
      <dc:creator>bailunrui</dc:creator>
      <dc:date>2014-02-05T18:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: Running total, but in cycles with roll over</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-total-but-in-cycles-with-roll-over/m-p/164243#M31763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you provide a better explanation of what goes into the total?&amp;nbsp; It appears that it is simply the event number until event number is less than the previous event number and then, for some, appears like the total is the event number added onto a cummulative sum.&amp;nbsp; But that doesn't appear to hold for your example.&amp;nbsp; Please explain.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Feb 2014 18:29:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-total-but-in-cycles-with-roll-over/m-p/164243#M31763</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-02-05T18:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: Running total, but in cycles with roll over</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-total-but-in-cycles-with-roll-over/m-p/164244#M31764</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Up until 255, it is just the event number.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After 255, it is the event number + 255.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If 255 comes up again, it is the event number + 255 + 255.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Feb 2014 19:05:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-total-but-in-cycles-with-roll-over/m-p/164244#M31764</guid>
      <dc:creator>bailunrui</dc:creator>
      <dc:date>2014-02-05T19:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: Running total, but in cycles with roll over</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-total-but-in-cycles-with-roll-over/m-p/164245#M31765</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The following may do what you want:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (drop=base last);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by person;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first.person then base=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; last=lag(event_number);&lt;/P&gt;&lt;P&gt;&amp;nbsp; if not first.person and event_number lt last then base+255;&lt;/P&gt;&lt;P&gt;&amp;nbsp; total=sum(event_number,base);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Feb 2014 19:26:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-total-but-in-cycles-with-roll-over/m-p/164245#M31765</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-02-05T19:26:25Z</dc:date>
    </item>
    <item>
      <title>Re: Running total, but in cycles with roll over</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-total-but-in-cycles-with-roll-over/m-p/164246#M31766</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That totally worked, thank you!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Feb 2014 19:53:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-total-but-in-cycles-with-roll-over/m-p/164246#M31766</guid>
      <dc:creator>bailunrui</dc:creator>
      <dc:date>2014-02-05T19:53:50Z</dc:date>
    </item>
  </channel>
</rss>

