<?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: culmulative sum by group using Proc SQL in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517597#M3354</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/89720"&gt;@sameer112217&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;For some reason I have to use PROC SQL to do cumulative sum for the number variables but I am unable to do it using Proc SQL&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I'm not surprised, this is NOT easy to do (if it is possible at all) in PROC SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't know why you feel restricted to doing it in PROC SQL, but I have no such restrictions, so for everyone else reading along, this is a very simple method without SQL to compute these cumulative sums.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have nway;
    var premiumamount sum_assured;
    class fiscal_year premium_date;
    output out=sums sum=;
run;
data want;
    set sums;
    by fiscal_year;
    if first.fiscal_year then do;
         cumulative_premiumamount=0;
         cumulative_sum_assured=0;
    end;
    cumulative_premiumamount+premiumamount;
    cumulative_sum_assured+sum_assured;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 30 Nov 2018 17:58:16 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2018-11-30T17:58:16Z</dc:date>
    <item>
      <title>culmulative sum by group using Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517593#M3353</link>
      <description>&lt;P&gt;For some reason I have to use PROC SQL to do cumulative sum for the number variables but I am unable to do it using Proc SQL&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Fiscal_year&amp;nbsp; &amp;nbsp;Premium_date&amp;nbsp; type&amp;nbsp; &amp;nbsp; &amp;nbsp;premiumamount&amp;nbsp; sum_assured&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2016-17&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01JAN&lt;/SPAN&gt;&lt;SPAN&gt;2017&amp;nbsp; &amp;nbsp; &amp;nbsp; corp&amp;nbsp; &amp;nbsp; &amp;nbsp;100&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;100&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2016-17&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01JAN&lt;/SPAN&gt;&lt;SPAN&gt;2017&amp;nbsp; &amp;nbsp; &amp;nbsp; corp&amp;nbsp; &amp;nbsp; &amp;nbsp;100&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;100&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;2016-17&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01FEB2017&amp;nbsp; &amp;nbsp; &amp;nbsp; corp&amp;nbsp; &amp;nbsp; &amp;nbsp;200&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;200&lt;/P&gt;&lt;P&gt;2016-17&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;01FEB&lt;/SPAN&gt;&lt;SPAN&gt;2017&amp;nbsp; &amp;nbsp; &amp;nbsp; corp&amp;nbsp; &amp;nbsp; &amp;nbsp;200&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;200&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I used&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;PROC SQL;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Create table want as&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Select fiscal_year, premium_date, type, sum(premiumamount) as YTD_Premiumamount,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;sum(sum_assured) as YTD_sum_assured&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;from table1 as a&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;group by fiscal_year, premium_date, type&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;quit&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I would get result like this&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;fiscal_year&amp;nbsp; &amp;nbsp;Premium_date&amp;nbsp; type&amp;nbsp; &amp;nbsp; &amp;nbsp;YTD_premiumamount&amp;nbsp; YTD_sum_assured&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;2016-17&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01JAN2017&amp;nbsp; &amp;nbsp; &amp;nbsp; corp&amp;nbsp; &amp;nbsp; &amp;nbsp;200&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;200&lt;/P&gt;&lt;P&gt;2016-17&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01FEB2017&amp;nbsp; &amp;nbsp; &amp;nbsp; corp&amp;nbsp; &amp;nbsp; 400&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 400&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But I want like this which is culmulative sum YTD&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;fiscal_year&amp;nbsp; Premium_date&amp;nbsp; type&amp;nbsp; &amp;nbsp; YTD_premiumamount&amp;nbsp; YTD_sum_assured&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2016-17&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01JAN&lt;/SPAN&gt;&lt;SPAN&gt;2017&amp;nbsp; &amp;nbsp; &amp;nbsp; corp&amp;nbsp; &amp;nbsp; &amp;nbsp;200&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;200&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;2016-17&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01FEB2017&amp;nbsp; &amp;nbsp; &amp;nbsp; corp&amp;nbsp; &amp;nbsp; &amp;nbsp;600&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;600&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In short it should have cumulative sum&amp;nbsp;of measures until the fiscal year ends in 31mar2017. I have tried in data step using first.var but want in Proc SQL&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 17:51:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517593#M3353</guid>
      <dc:creator>sameer112217</dc:creator>
      <dc:date>2018-11-30T17:51:41Z</dc:date>
    </item>
    <item>
      <title>Re: culmulative sum by group using Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517597#M3354</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/89720"&gt;@sameer112217&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;For some reason I have to use PROC SQL to do cumulative sum for the number variables but I am unable to do it using Proc SQL&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I'm not surprised, this is NOT easy to do (if it is possible at all) in PROC SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't know why you feel restricted to doing it in PROC SQL, but I have no such restrictions, so for everyone else reading along, this is a very simple method without SQL to compute these cumulative sums.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have nway;
    var premiumamount sum_assured;
    class fiscal_year premium_date;
    output out=sums sum=;
run;
data want;
    set sums;
    by fiscal_year;
    if first.fiscal_year then do;
         cumulative_premiumamount=0;
         cumulative_sum_assured=0;
    end;
    cumulative_premiumamount+premiumamount;
    cumulative_sum_assured+sum_assured;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Nov 2018 17:58:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517597#M3354</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-11-30T17:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: culmulative sum by group using Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517599#M3355</link>
      <description>&lt;P&gt;May we know what is that&amp;nbsp;&lt;STRONG&gt;some reason&lt;/STRONG&gt; that precludes the usage of datastep/other summary procs assuming you have a commercial or student SAS software version.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/89720"&gt;@sameer112217&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;For &lt;STRONG&gt;some reason&lt;/STRONG&gt; I have to use PROC SQL to do cumulative sum for the number variables but I am unable to do it using Proc SQL&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 18:09:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517599#M3355</guid>
      <dc:creator>MarkWik</dc:creator>
      <dc:date>2018-11-30T18:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: culmulative sum by group using Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517600#M3356</link>
      <description>&lt;P&gt;As a matter of fact, we the community including you can build up supportive arguments to challenge your boss/team/peers who may have assigned you such tasks with real legitimate reasons&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 18:11:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517600#M3356</guid>
      <dc:creator>MarkWik</dc:creator>
      <dc:date>2018-11-30T18:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: culmulative sum by group using Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517612#M3357</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Fiscal_year $  Premium_date :date9. type   $  premiumamount  sum_assured;
format Premium_date date9.;
cards;
2016-17       01JAN2017      corp     100                       100
2016-17       01JAN2017      corp     100                       100
2016-17       01FEB2017      corp     200                       200
2016-17       01FEB2017      corp     200                       200
;
proc sql;
create table temp as
select fiscal_year, premium_date, type, sum(premiumamount) as YTD_Premiumamount,sum(sum_assured) as YTD_sum_assured
from have 
group by fiscal_year, premium_date, type;
quit;
proc sql;
create table want as
select a.Fiscal_year ,a.Premium_date ,a.type,sum(b.YTD_Premiumamount) as YTD_Premiumamount,sum(b.YTD_sum_assured) as YTD_sum_assured 
from temp a inner join temp b
on a.Fiscal_year   =b.Fiscal_year    and a.type=b.type and  b.Premium_date&amp;lt;=a.Premium_date  
group by a.fiscal_year,a.premium_date,a.type
order by a.fiscal_year,a.Premium_date,a.type;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Nov 2018 19:21:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517612#M3357</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-30T19:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: culmulative sum by group using Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517614#M3358</link>
      <description>&lt;P&gt;Ok, this uses PROC SQL but is a whole lot easier than I thought it would be &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have nway;
    var premiumamount sum_assured;
    class fiscal_year premium_date;
    output out=sums sum=;
run;
data sums1;
    set sums;
    by fiscal_year;
    if first.fiscal_year then do;
         cumulative_premiumamount=0;
         cumulative_sum_assured=0;
    end;
    cumulative_premiumamount+premiumamount;
    cumulative_sum_assured+sum_assured;
run;
proc sql;
    create table cumulative_sums as select * from sums1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Nov 2018 23:53:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517614#M3358</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-11-30T23:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: culmulative sum by group using Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517615#M3359</link>
      <description>&lt;P&gt;lol point taken. You must have had&amp;nbsp; a pretty good lunch. I just had bigMAC haha&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 19:27:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517615#M3359</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-30T19:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: culmulative sum by group using Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517638#M3368</link>
      <description>&lt;P&gt;You shouldn't do this. It's inefficient and better done in a data step and is probably faster there too.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But since most people ignore that advice here's one solution. I highly suspect this could be simplified, but since you have repeating values for each month, the data first needs to be summaries to a monthly level then the cumulative month calculation can occur, otherwise when you join you get too&amp;nbsp;duplicate records because the keys are not unique and then your numbers are duplicated.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	data have;
input Fiscal_year $  Premium_date :date9. type   $  premiumamount  sum_assured;
format Premium_date date9.;
cards;
2016-17       01JAN2017      corp     100                       100
2016-17       01JAN2017      corp     100                       100
2016-17       01FEB2017      corp     200                       200
2016-17       01FEB2017      corp     200                       200
;


proc sql;
create table want as 
select h1.fiscal_year, h1.premium_date, sum(h2.T_amount) as YTD_premium, sum(h2.T_assured) as YTD_assured
from 
	(select fiscal_year, premium_date, type, sum(premiumamount) as T_amount, sum(sum_assured) as T_assured
	from have
	group by fiscal_year, premium_date, type) as h1
left join 
	(select fiscal_year, premium_date, type, sum(premiumamount) as T_amount, sum(sum_assured) as T_assured
	from have
	group by fiscal_year, premium_date, type) as h2

on h2.premium_date &amp;lt;= h1.premium_date
and h1.fiscal_year=h2.fiscal_year
and h1.type=h2.type
group by h1.fiscal_year, h1.premium_date;
quit;


&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Nov 2018 20:16:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517638#M3368</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-30T20:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: culmulative sum by group using Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517649#M3370</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp; While it is trivial in this thread and I am 100% certain, a professional orgranization will/should not resort to SQL for this, I'm afraid your 2*summary times initial and then group by product and filter will slow down the process as opposed to having summary done in one go and one by group product &amp;amp; filter before the final summary,&amp;nbsp; hence was my approach.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But of course you made me think what I could have done better, and that is get the temp as view rather than a table as follows.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Fiscal_year $  Premium_date :date9. type   $  premiumamount  sum_assured;
format Premium_date date9.;
cards;
2016-17       01JAN2017      corp     100                       100
2016-17       01JAN2017      corp     100                       100
2016-17       01FEB2017      corp     200                       200
2016-17       01FEB2017      corp     200                       200
;
/*create view temp */
proc sql;
create view temp as
select fiscal_year, premium_date, type, sum(premiumamount) as YTD_Premiumamount,sum(sum_assured) as YTD_sum_assured
from have 
group by fiscal_year, premium_date, type;
quit;

proc sql;
create table want as
select a.Fiscal_year ,a.Premium_date ,a.type,sum(b.YTD_Premiumamount) as YTD_Premiumamount,sum(b.YTD_sum_assured) as YTD_sum_assured 
from temp a inner join temp b
on a.Fiscal_year   =b.Fiscal_year    and a.type=b.type and  b.Premium_date&amp;lt;=a.Premium_date  
group by a.fiscal_year,a.premium_date,a.type
order by a.fiscal_year,a.Premium_date,a.type;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;which should improve efficiency.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My two cents!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 20:38:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517649#M3370</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-30T20:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: culmulative sum by group using Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517651#M3371</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;While it is trivial in this thread and I am 100% certain, a professional orgranization will/should not resort to SQL for this, I'm afraid your 2*summary times initial and then group by product and filter will slow down the process as opposed to having summary done in one go and one by group product &amp;amp; filter before the final summary,&amp;nbsp; hence was my approach.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The question explicitly asks for an inefficient solution though &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 20:40:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517651#M3371</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-30T20:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: culmulative sum by group using Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517654#M3372</link>
      <description>&lt;P&gt;In my opinion, another benefit of not using PROC SQL here is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code I originally provided is much more readable and understandable and maintainable than any PROC SQL solution in this thread. If a new person had to take over the code, I think there's a much better chance that the new person would understand the PROC SUMMARY/DATA step solution than the SQL solutions.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 20:43:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517654#M3372</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-11-30T20:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: culmulative sum by group using Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517656#M3373</link>
      <description>&lt;P&gt;So true. And believe it or not,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I had a very similar VIZ Almost same question in a HW and here is a feedback from my Prof lol&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="d2l-navigation-centerer style-scope d2l-navigation-header"&gt;
&lt;DIV class="d2l-navigation-gutters style-scope d2l-navigation-header"&gt;
&lt;DIV class="d2l-navigation-header-container style-scope d2l-navigation-header"&gt;
&lt;DIV class="d2l-navigation-header-left"&gt;
&lt;DIV class="d2l-navigation-s-header-logo-area d2l-navigation-s-header-no-home-icon"&gt;
&lt;DIV class="d2l-navigation-s-logo"&gt;
&lt;DIV class="d2l-navigation-s-logo-wrapper"&gt;&lt;A class="d2l-navigation-s-logo-link" title="My Home" href="https://d2l.depaul.edu/d2l/lp/ouHome/defaultHome.d2l" target="_blank"&gt;&lt;IMG src="https://d2l.depaul.edu/d2l/lp/navbars/6605/theme/viewimage/6387405/view?v=10.8.7.13617-324" border="0" alt="My Home" /&gt;&lt;/A&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="d2l-navigation-s-title-container"&gt;&lt;A class="d2l-navigation-s-link" title="DATABASE PROGRAMMING - 2018-2019 Autumn" href="https://d2l.depaul.edu/d2l/home/642316" target="_blank"&gt;DATABASE PROGRAMMING - 2018-2019 Autumn&lt;/A&gt;&amp;nbsp; &lt;STRONG&gt;ORACLE PL/SQL&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="d2l-navigation-gutter style-scope d2l-navigation-header"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="d2l-navigation-s-main d2l-navigation-main-tb d2l-branding-navigation-background-color d2l-visible-on-ancestor-target"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE id="z_a" class="d2l-table d2l-grid d_gl" summary="List of grade items and their values"&gt;
&lt;TBODY&gt;
&lt;TR class="d_gh d2l-table-row-first"&gt;
&lt;TH class="d_hch d_gl d2l-table-cell-first" scope="col"&gt;Grade Item&lt;/TH&gt;
&lt;TH class="d_hch d_gr" scope="col"&gt;Points&lt;/TH&gt;
&lt;TH class="d_hch d_gr" scope="col"&gt;Grade&lt;/TH&gt;
&lt;TH class="d_hch d_gl d2l-table-cell-last" scope="col"&gt;Feedback&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="d_gt d_ich d2l-table-cell-first" scope="row"&gt;
&lt;DIV class="dco"&gt;
&lt;DIV class="dco_c"&gt;
&lt;DIV class="dco"&gt;
&lt;DIV class="dco_c"&gt;&lt;LABEL&gt;HW2&lt;/LABEL&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/TH&gt;
&lt;TD class="d_gn d_gr d_gt"&gt;
&lt;DIV class="dco"&gt;
&lt;DIV class="dco_c"&gt;
&lt;DIV class="dco"&gt;
&lt;DIV class="dco_c"&gt;
&lt;DIV&gt;
&lt;DIV id="z_b" class="dco"&gt;
&lt;DIV class="dco_c"&gt;&lt;LABEL id="z_d"&gt;90 / 100&lt;/LABEL&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD class="d_gn d_gr d_gt"&gt;
&lt;DIV class="dco"&gt;
&lt;DIV class="dco_c"&gt;
&lt;DIV&gt;
&lt;DIV id="z_f" class="dco"&gt;
&lt;DIV class="dco_c"&gt;&lt;LABEL id="z_h"&gt;90 %&lt;/LABEL&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD class="d_gt d2l-table-cell-last"&gt;
&lt;DIV class="dco d2l-grades-individualcommentlabelcontainer"&gt;
&lt;DIV class="dco_c"&gt;
&lt;DIV class="dco d2l-body-small"&gt;
&lt;DIV class="dco_c"&gt;&lt;LABEL&gt;Individual Feedback&lt;/LABEL&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="drt d2l-htmlblock d2l-htmlblock-untrusted d2l-htmlblock-deferred"&gt;
&lt;P&gt;Part I:&lt;/P&gt;
&lt;P&gt;Good, but &lt;STRONG&gt;not efficient solution&lt;/STRONG&gt;, try using "Cursor/Merge".You should have challenged me&lt;/P&gt;
&lt;P&gt;Part II:&lt;/P&gt;
&lt;P&gt;Good.&lt;/P&gt;
&lt;P&gt;Part III: -1&lt;/P&gt;
&lt;P&gt;The result of your query should display ALL projectNo even if the quantity is "0". Plus the sum is Quantity Not PartNo.&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Fri, 30 Nov 2018 20:43:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517656#M3373</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-30T20:43:41Z</dc:date>
    </item>
    <item>
      <title>Re: culmulative sum by group using Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517659#M3374</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;The question explicitly asks for an inefficient solution though &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;My current philosophy for situations where the user excludes the most appropriate and efficient method is that I will give the answer I want to give, without the original restrictions, because someone (perhaps not the original poster) may benefit. And of course, sometimes the original poster may "see the light" and benefit as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only time I try to follow the originally stated restrictions is if a user has not licensed the proper SAS&amp;nbsp; product, for example, PROC EXPAND in SAS/ETS, and wants to replicate some of the functionality in PROC EXPAND using DATA steps or other PROCs that the user has available.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 20:48:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517659#M3374</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-11-30T20:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: culmulative sum by group using Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517660#M3375</link>
      <description>&lt;P&gt;But I am sure you will grant "partial credit" if you were to grade? (winks)&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 20:51:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517660#M3375</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-30T20:51:34Z</dc:date>
    </item>
    <item>
      <title>Re: culmulative sum by group using Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517724#M3392</link>
      <description>&lt;P&gt;Finding a context where this request would be legitimate requires a&amp;nbsp;fertile imagination, but it can be a fun exercise. Here is a single query variation on the theme initiated by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select 
    a.Fiscal_year,
    a.Premium_date,
    a.type,
    sum(b.premiumAmount) as YTD_PremiumAmount,
    sum(b.sum_assured) as YTD_sum_assured 
from
  ( select distinct
        a.Fiscal_year,
        a.Premium_date,
        a.type,
        b.Premium_date as other_date
    from have as a inner join have as b 
        on  a.Fiscal_year = b.Fiscal_year and 
            a.type = b.type and 
            a.Premium_date &amp;gt;= b.Premium_date ) as a inner join
    have as b 
        on  a.Fiscal_year = b.Fiscal_year and 
            a.type = b.type and
            a.other_date = b.Premium_date
group by
    a.Fiscal_year,
    a.Premium_date,
    a.type
;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 01 Dec 2018 06:48:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/517724#M3392</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-12-01T06:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: culmulative sum by group using Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/518302#M3514</link>
      <description>&lt;P&gt;Thank you everyone. You all guys are awesome. I have got the solution from your solutions.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 04:49:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/culmulative-sum-by-group-using-Proc-SQL/m-p/518302#M3514</guid>
      <dc:creator>sameer112217</dc:creator>
      <dc:date>2018-12-04T04:49:08Z</dc:date>
    </item>
  </channel>
</rss>

