<?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: Cumulative sum in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Cumulative-sum/m-p/61106#M17327</link>
    <description>An approach without datastep would be:&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=&lt;DSNAME&gt;; by meter date;run;&lt;BR /&gt;
&lt;BR /&gt;
proc freq data=&lt;DSNAME&gt; noprint;&lt;BR /&gt;
by meter;&lt;BR /&gt;
tables date/list outcum out=&lt;NEW dsname=""&gt; (drop=percent cum_pct rename=(count=demand cum_freq=cal));&lt;BR /&gt;
weight demand;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
You'll have labels for the demand and cal variable related to frequency count but that's fixeable lots of ways. May not do what you want if any demand values are missing or negative.&lt;/NEW&gt;&lt;/DSNAME&gt;&lt;/DSNAME&gt;</description>
    <pubDate>Tue, 04 Aug 2009 22:45:06 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2009-08-04T22:45:06Z</dc:date>
    <item>
      <title>Cumulative sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Cumulative-sum/m-p/61104#M17325</link>
      <description>data is as follows &lt;BR /&gt;
 date    meter   demand      cal; &lt;BR /&gt;
1         A            5              5 &lt;BR /&gt;
2         B           10             15 &lt;BR /&gt;
3         C           15             30 &lt;BR /&gt;
4         D           20             50 &lt;BR /&gt;
5         E           25             75 &lt;BR /&gt;
6         F           30             105 &lt;BR /&gt;
7         G          35             140 &lt;BR /&gt;
8         H          40             1 80 &lt;BR /&gt;
&lt;BR /&gt;
in this table &lt;BR /&gt;
there are three variables and "cal" is the result i require &lt;BR /&gt;
so &lt;BR /&gt;
i need the code such as i get the cumulative sum as shown in "Cal" &lt;BR /&gt;
my input are date,meter(charachter) and demand and i need "cal" which &lt;BR /&gt;
is shown in the table &lt;BR /&gt;
and i need to sort it by meter and date &lt;BR /&gt;
like for meter A (date 1 to &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; its "cal" &lt;BR /&gt;
then meter B (date 1 to &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; its "cal" &lt;BR /&gt;
so, please do reply if u have an answer for this query &lt;BR /&gt;
thanks</description>
      <pubDate>Mon, 03 Aug 2009 07:40:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Cumulative-sum/m-p/61104#M17325</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-08-03T07:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Cumulative-sum/m-p/61105#M17326</link>
      <description>Hi!&lt;BR /&gt;
&lt;BR /&gt;
First sort the data as you wish.&lt;BR /&gt;
see PROC SORT procedure: &lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/sort-overview.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/sort-overview.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Then through datastep add the DEMAND variable to a CAL retained variable.&lt;BR /&gt;
see how to RETAIN a value: &lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000214163.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000214163.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Cheers from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;.</description>
      <pubDate>Mon, 03 Aug 2009 07:55:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Cumulative-sum/m-p/61105#M17326</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2009-08-03T07:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Cumulative-sum/m-p/61106#M17327</link>
      <description>An approach without datastep would be:&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=&lt;DSNAME&gt;; by meter date;run;&lt;BR /&gt;
&lt;BR /&gt;
proc freq data=&lt;DSNAME&gt; noprint;&lt;BR /&gt;
by meter;&lt;BR /&gt;
tables date/list outcum out=&lt;NEW dsname=""&gt; (drop=percent cum_pct rename=(count=demand cum_freq=cal));&lt;BR /&gt;
weight demand;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
You'll have labels for the demand and cal variable related to frequency count but that's fixeable lots of ways. May not do what you want if any demand values are missing or negative.&lt;/NEW&gt;&lt;/DSNAME&gt;&lt;/DSNAME&gt;</description>
      <pubDate>Tue, 04 Aug 2009 22:45:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Cumulative-sum/m-p/61106#M17327</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2009-08-04T22:45:06Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Cumulative-sum/m-p/61107#M17328</link>
      <description>A CUMSUM&lt;BR /&gt;
1   5       5 &lt;BR /&gt;
2  10     15 &lt;BR /&gt;
3  15     30 &lt;BR /&gt;
4  20     50 &lt;BR /&gt;
5  25     75 &lt;BR /&gt;
6  30   105 &lt;BR /&gt;
7  35   140 &lt;BR /&gt;
8  40   180 &lt;BR /&gt;
&lt;BR /&gt;
Hello,&lt;BR /&gt;
&lt;BR /&gt;
I just want to calculate CUMSUM column  (cumulative sum of column A). Do I still have to use RETAIN? I found the following sample code, but;&lt;BR /&gt;
&lt;BR /&gt;
data a; &lt;BR /&gt;
      set a; &lt;BR /&gt;
      xsum + x; &lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Mon, 17 Jan 2011 10:40:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Cumulative-sum/m-p/61107#M17328</guid>
      <dc:creator>kggunes</dc:creator>
      <dc:date>2011-01-17T10:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Cumulative-sum/m-p/61108#M17329</link>
      <description>using the syntax &lt;BR /&gt;
&lt;BR /&gt;
A + B;&lt;BR /&gt;
&lt;BR /&gt;
(with no = sign) does an implicit retain.</description>
      <pubDate>Tue, 18 Jan 2011 02:46:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Cumulative-sum/m-p/61108#M17329</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2011-01-18T02:46:51Z</dc:date>
    </item>
  </channel>
</rss>

