<?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: Calculating cumulative sum in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Calculating-cumulative-sum/m-p/145801#M2399</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for the answer!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is really short but I couldn't figure it out because its not so intuitive (at least to me) because I was trying to do something like setting the first cumsum to the value itself and for the rest of values to make cumsum by adding the value to the sum( ) of the previous values and I was getting a mess...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 11 Dec 2014 04:52:42 GMT</pubDate>
    <dc:creator>ilikesas</dc:creator>
    <dc:date>2014-12-11T04:52:42Z</dc:date>
    <item>
      <title>Calculating cumulative sum</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Calculating-cumulative-sum/m-p/145799#M2397</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;my question might be too simple but I actually have some trouble figuring it out...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what I want to do is to calculate the cumulative sum of a column, so if I have the following table:&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="124" style="border: 1px solid rgb(0, 0, 0); width: 99px; height: 123px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;value&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;40&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to add to it the following column:&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="144" style="border: 1px solid rgb(0, 0, 0); width: 126px; height: 146px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;cummulative sum&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;60&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Dec 2014 04:12:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Calculating-cumulative-sum/m-p/145799#M2397</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2014-12-11T04:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating cumulative sum</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Calculating-cumulative-sum/m-p/145800#M2398</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;retain cum_sum;&lt;/P&gt;&lt;P&gt;cum_sum+value;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Dec 2014 04:19:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Calculating-cumulative-sum/m-p/145800#M2398</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-12-11T04:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating cumulative sum</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Calculating-cumulative-sum/m-p/145801#M2399</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for the answer!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is really short but I couldn't figure it out because its not so intuitive (at least to me) because I was trying to do something like setting the first cumsum to the value itself and for the rest of values to make cumsum by adding the value to the sum( ) of the previous values and I was getting a mess...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Dec 2014 04:52:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Calculating-cumulative-sum/m-p/145801#M2399</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2014-12-11T04:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating cumulative sum</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Calculating-cumulative-sum/m-p/145802#M2400</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Technically you don't even need the retain statement, the + implies the retain so the following works as well:&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;data want;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;set have;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;cum_sum+value;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Dec 2014 05:05:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Calculating-cumulative-sum/m-p/145802#M2400</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-12-11T05:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating cumulative sum</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Calculating-cumulative-sum/m-p/145803#M2401</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Reeza its me again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now I would like to add another level of complexity, if I may:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;assume that in the previous case I had to calculate the cumulative sum for one company, but now I need to do the same thing but for many companies, so each time I get to a new company the cumulative sum restarts calculating.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Dec 2014 05:06:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Calculating-cumulative-sum/m-p/145803#M2401</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2014-12-11T05:06:44Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating cumulative sum</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Calculating-cumulative-sum/m-p/145804#M2402</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Hi,&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;For many companies you need by processing. Just make sure data is sorted by company variable.&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data want;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;set have;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;by &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;company&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;if first.&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;company&lt;/SPAN&gt; then &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;cum_sum&lt;/SPAN&gt;=0;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;cum_sum+value;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Dec 2014 05:51:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Calculating-cumulative-sum/m-p/145804#M2402</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-12-11T05:51:53Z</dc:date>
    </item>
  </channel>
</rss>

