<?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 Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/CUMULATIVE-SUM/m-p/506877#M135914</link>
    <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;many tnks for your solution ,&lt;/P&gt;&lt;P&gt;have a good afternoon !!!&lt;/P&gt;&lt;P&gt;Tecla&lt;/P&gt;</description>
    <pubDate>Tue, 23 Oct 2018 15:33:26 GMT</pubDate>
    <dc:creator>Tecla1</dc:creator>
    <dc:date>2018-10-23T15:33:26Z</dc:date>
    <item>
      <title>CUMULATIVE SUM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CUMULATIVE-SUM/m-p/506748#M135836</link>
      <description>&lt;P&gt;Good morning, I have a big table and I need to make a cumulative sum with relative percent, like this :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;type&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;date&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;amount&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;cumulative&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;cumulative perc.&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;01/02/2018&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;35,71%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;02/02/2018&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;700&lt;/TD&gt;&lt;TD&gt;50,00%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;03/02/2018&lt;/TD&gt;&lt;TD&gt;700&lt;/TD&gt;&lt;TD&gt;1400&lt;/TD&gt;&lt;TD&gt;100,00%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;01/02/2018&lt;/TD&gt;&lt;TD&gt;300&lt;/TD&gt;&lt;TD&gt;300&lt;/TD&gt;&lt;TD&gt;60,00%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;02/02/2018&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;100,00%&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you help me? Which function I have to use?&lt;/P&gt;&lt;P&gt;Many Thanks for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2018 08:26:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CUMULATIVE-SUM/m-p/506748#M135836</guid>
      <dc:creator>Tecla1</dc:creator>
      <dc:date>2018-10-23T08:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: CUMULATIVE SUM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CUMULATIVE-SUM/m-p/506753#M135840</link>
      <description>&lt;P&gt;Post test data in the form of a datastep in future please, as such this code is untested:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table inter as
  select a.*,
         b.tot
  from   have a
  left join (select type,sum(amount) as tot from have group by type) b
  on     a.type=b.type;
quit;

data want;
  set inter;
  retain cumulative;
  by type;
  cumulative=ifn(first.type,amount,sum(cumulative,amount));
  cumulative_perc=(cumulative/tot) * 100;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Oct 2018 09:02:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CUMULATIVE-SUM/m-p/506753#M135840</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-10-23T09:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: CUMULATIVE SUM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CUMULATIVE-SUM/m-p/506761#M135847</link>
      <description>&lt;P&gt;Or use a double do loop:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
sum = 0;
do until(last.type);
  set have;
  by type;
  sum + amount;
end;
cumulative = 0;
do until(last.type);
  set have;
  by type;
  cumulative + amount;
  cum_percent = cumulative / sum;
  output;
end;
drop sum;
format cum_percent percent9.2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Oct 2018 10:02:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CUMULATIVE-SUM/m-p/506761#M135847</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-23T10:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: CUMULATIVE SUM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CUMULATIVE-SUM/m-p/506762#M135848</link>
      <description>&lt;P&gt;Hi, Tnks to all, now I try … I will give you a feed back.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2018 10:17:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CUMULATIVE-SUM/m-p/506762#M135848</guid>
      <dc:creator>Tecla1</dc:creator>
      <dc:date>2018-10-23T10:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: CUMULATIVE SUM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CUMULATIVE-SUM/m-p/506778#M135859</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;data want1;
set have;
by type;
retain cumulative;
if first.type then cumulative=amount;
else cumulative+amount;
run;

proc sql;
create table want as
select  type,date,amount,cumulative,(cumulative/max_amount)*100 format=percent8.2 as per from(
select type,date,amount,cumulative,max(cumulative)as max_amount from want1 group by type) order by type,cumulative ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Oct 2018 10:54:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CUMULATIVE-SUM/m-p/506778#M135859</guid>
      <dc:creator>singhsahab</dc:creator>
      <dc:date>2018-10-23T10:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: CUMULATIVE SUM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CUMULATIVE-SUM/m-p/506877#M135914</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;many tnks for your solution ,&lt;/P&gt;&lt;P&gt;have a good afternoon !!!&lt;/P&gt;&lt;P&gt;Tecla&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2018 15:33:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CUMULATIVE-SUM/m-p/506877#M135914</guid>
      <dc:creator>Tecla1</dc:creator>
      <dc:date>2018-10-23T15:33:26Z</dc:date>
    </item>
  </channel>
</rss>

