<?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: Aggregate data and sum in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668331#M79113</link>
    <description>&lt;P&gt;You can do this in PROC REPORT, it's pretty simple. I wasn't able to get the "Total" column at the right, and so I'm sure someone (&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;?&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;&amp;nbsp;?) out there can guide me on how to get that "Total" column using PROC REPORT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the rest of the table (without the "total" column at the right) using PROC REPORT&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=have;
    columns date code,amount;
    define date/group;
    define code/across;
    define amount/analysis sum;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 10 Jul 2020 11:42:04 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-07-10T11:42:04Z</dc:date>
    <item>
      <title>Aggregate data and sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668296#M79104</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table with several informations (see table below):&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/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/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;31.01.2020&lt;/TD&gt;&lt;TD&gt;75&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;29.02.2020&lt;/TD&gt;&lt;TD&gt;65&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;31.03.2020&lt;/TD&gt;&lt;TD&gt;80&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;30.04.2020&lt;/TD&gt;&lt;TD&gt;90&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;31.01.2020&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;29.02.2020&lt;/TD&gt;&lt;TD&gt;350&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;31.03.2020&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;30.04.2020&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and I want to aggregate the data based on the date and sum it up for each code (in excel it would be done in a pivot table), so that my final table looks like:&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;Code0&lt;/TD&gt;&lt;TD&gt;Code1&lt;/TD&gt;&lt;TD&gt;Code2&lt;/TD&gt;&lt;TD&gt;Code3&lt;/TD&gt;&lt;TD&gt;Code4&lt;/TD&gt;&lt;TD&gt;Total&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;31.01.2020&lt;/TD&gt;&lt;TD&gt;600&lt;/TD&gt;&lt;TD&gt;75&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;875&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;29.02.2020&lt;/TD&gt;&lt;TD&gt;350&lt;/TD&gt;&lt;TD&gt;145&lt;/TD&gt;&lt;TD&gt;150&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;645&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;31.03.2020&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;120&lt;/TD&gt;&lt;TD&gt;80&lt;/TD&gt;&lt;TD&gt;125&lt;/TD&gt;&lt;TD&gt;525&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;30.04.2020&lt;/TD&gt;&lt;TD&gt;230&lt;/TD&gt;&lt;TD&gt;175&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;90&lt;/TD&gt;&lt;TD&gt;495&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the ID is irrelevant for my final table, I want to calculate the sum over the amount for each Code and month and in the last column a total for each month. If possible I would like to do it with an proc sql rather than a proc summary.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope it is clear what I need.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2020 08:58:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668296#M79104</guid>
      <dc:creator>Jay_Aguilar</dc:creator>
      <dc:date>2020-07-10T08:58:37Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate data and sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668297#M79105</link>
      <description>&lt;P&gt;Is this for reporting purposes or do you need a SAS data set like this?&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2020 08:59:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668297#M79105</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-07-10T08:59:59Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate data and sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668298#M79106</link>
      <description>It is rather for reporting purpose.</description>
      <pubDate>Fri, 10 Jul 2020 09:02:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668298#M79106</guid>
      <dc:creator>Jay_Aguilar</dc:creator>
      <dc:date>2020-07-10T09:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate data and sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668299#M79107</link>
      <description>&lt;P&gt;So are you ok with Proc Tabulate or Proc Report?&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2020 09:03:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668299#M79107</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-07-10T09:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate data and sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668300#M79108</link>
      <description>I guess proc tabulate would also work, dont have too much experience with proc report. Is proc sql too long/complicated for this problem?</description>
      <pubDate>Fri, 10 Jul 2020 09:05:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668300#M79108</guid>
      <dc:creator>Jay_Aguilar</dc:creator>
      <dc:date>2020-07-10T09:05:17Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate data and sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668310#M79109</link>
      <description>&lt;P&gt;How about&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID Code Date :anydtdte. Amount;
format date ddmmyy10.;
datalines;
1 0 31.01.2020 100
1 1 29.02.2020 80
1 2 31.03.2020 120
1 1 30.04.2020 75
2 2 31.01.2020 200
2 2 29.02.2020 150
2 4 31.03.2020 125
2 0 30.04.2020 230
3 1 31.01.2020 75
3 1 29.02.2020 65
3 3 31.03.2020 80
3 4 30.04.2020 90
4 0 31.01.2020 500
4 0 29.02.2020 350
4 1 31.03.2020 200
4 1 30.04.2020 100
;

proc format;
   picture p other = '00009' (prefix='Code');
run;

proc tabulate data=have out=want format=8.;
   class Code Date;
   var Amount;
   keylabel sum=' ' all= ' ';
   format code p.;
   table date='', code=''*amount='' all*amount=''*(sum='Total') / box='Date';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Jul 2020 09:58:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668310#M79109</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-07-10T09:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate data and sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668321#M79111</link>
      <description>&lt;P&gt;Here is a way to do it by prod sql but later to tranpose it is good to use proc transpose&lt;/P&gt;
&lt;P&gt;&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 ID Code Date :anydtdte. Amount;
format date ddmmyy10.;
datalines;
1 0 31.01.2020 100
1 1 29.02.2020 80
1 2 31.03.2020 120
1 1 30.04.2020 75
2 2 31.01.2020 200
2 2 29.02.2020 150
2 4 31.03.2020 125
2 0 30.04.2020 230
3 1 31.01.2020 75
3 1 29.02.2020 65
3 3 31.03.2020 80
3 4 30.04.2020 90
4 0 31.01.2020 500
4 0 29.02.2020 350
4 1 31.03.2020 200
4 1 30.04.2020 100
;

proc sql;
create table want as select code, date, sum(amount) as suma from have group by code,date 
union all
select 9 as code, date, sum(amount) as suma from have group by date order by date, code;
quit; 

proc transpose data=want out=want2(rename=(code9=total)) prefix=code;
by date;
id code;
var suma;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2020 10:34:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668321#M79111</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-07-10T10:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate data and sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668322#M79112</link>
      <description>&lt;P&gt;have a try.&lt;/P&gt;&lt;P&gt;data raw;&lt;BR /&gt;input Code Date $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;P&gt;30.04.2020&lt;/P&gt;&lt;P&gt;100&lt;BR /&gt;p;&lt;BR /&gt;run;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table final&lt;BR /&gt;select distinct date, total&lt;BR /&gt;,sum ( code_0) as code0&lt;BR /&gt;,sum ( code_1) as code1&lt;BR /&gt;,sum ( code_2) as code2&lt;BR /&gt;,sum ( code_3) as code3&lt;BR /&gt;,sum ( code_4) as code4&lt;BR /&gt;from&lt;BR /&gt;(select date, sum(amount),case when code =0 then amount as code_0,&lt;BR /&gt;case when code =1 then amount as code_1,&lt;BR /&gt;case when code =2 then amount as code_2,&lt;BR /&gt;case when code=3 then amount as code_3,&lt;BR /&gt;case when code=4 then amount as code_4&lt;BR /&gt;from raw&lt;BR /&gt;group by date)&lt;BR /&gt;group by date;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2020 10:36:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668322#M79112</guid>
      <dc:creator>hyo_tree</dc:creator>
      <dc:date>2020-07-10T10:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate data and sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668331#M79113</link>
      <description>&lt;P&gt;You can do this in PROC REPORT, it's pretty simple. I wasn't able to get the "Total" column at the right, and so I'm sure someone (&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;?&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;&amp;nbsp;?) out there can guide me on how to get that "Total" column using PROC REPORT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the rest of the table (without the "total" column at the right) using PROC REPORT&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=have;
    columns date code,amount;
    define date/group;
    define code/across;
    define amount/analysis sum;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Jul 2020 11:42:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668331#M79113</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-10T11:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate data and sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668336#M79115</link>
      <description>Hi Paige,&lt;BR /&gt;For a pivot table , PROC TABULATE is better than REPORT .</description>
      <pubDate>Fri, 10 Jul 2020 12:02:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668336#M79115</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-07-10T12:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate data and sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668339#M79116</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi Paige,&lt;BR /&gt;For a pivot table , PROC TABULATE is better than REPORT .&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not if I don't know PROC TABULATE. And I don't really believe that it can't be done in PROC REPORT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;nevertheless, if anyone knows how to do this entirely with PROC REPORT, please advise. I think it's simple, but I just don't know how to do it. If I manipulate the data in PROC SUMMARY before I run PROC REPORT, I get the desired output.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2020 12:13:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668339#M79116</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-10T12:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate data and sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668340#M79117</link>
      <description>Thank you very much</description>
      <pubDate>Fri, 10 Jul 2020 12:10:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668340#M79117</guid>
      <dc:creator>Jay_Aguilar</dc:creator>
      <dc:date>2020-07-10T12:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate data and sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668341#M79118</link>
      <description>Thanks a lot for the help!</description>
      <pubDate>Fri, 10 Jul 2020 12:11:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668341#M79118</guid>
      <dc:creator>Jay_Aguilar</dc:creator>
      <dc:date>2020-07-10T12:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate data and sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668342#M79119</link>
      <description>Thank you, that is also an intersting way to do .</description>
      <pubDate>Fri, 10 Jul 2020 12:13:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668342#M79119</guid>
      <dc:creator>Jay_Aguilar</dc:creator>
      <dc:date>2020-07-10T12:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate data and sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668343#M79120</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi Paige,&lt;BR /&gt;For a pivot table , PROC TABULATE is better than REPORT .&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not if I don't know PROC TABULATE. And I don't really believe that it can't be done in PROC REPORT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;nevertheless, if anyone knows how to do this entirely with PROC REPORT, please advise. I think it's simple, but I just don't know how to do it. If I manipulate the data in PROC SUMMARY before I run PROC REPORT, I get the desired output.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Aha! By brute force trying a whole lot of possibilities (instead of the more intelligent method of looking at the documentation), I figured out how to get the Total column on the right. Example using SASHELP.CLASS:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=sashelp.class;
	columns sex age,height ("Total" height=sum);
	define sex/group;
	define age/across;
	define height/sum;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Jul 2020 12:21:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668343#M79120</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-10T12:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate data and sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668346#M79121</link>
      <description>Can you tell me what the Select 9 is doing?</description>
      <pubDate>Fri, 10 Jul 2020 12:24:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668346#M79121</guid>
      <dc:creator>Jay_Aguilar</dc:creator>
      <dc:date>2020-07-10T12:24:24Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate data and sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668348#M79122</link>
      <description>&lt;P&gt;Paige,&lt;/P&gt;
&lt;P&gt;As your wish , but that is not easy, you need change the code according to the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
input ID Code Date :anydtdte. Amount;
format date ddmmyy10.;
datalines;
1 0 31.01.2020 100
1 1 29.02.2020 80
1 2 31.03.2020 120
1 1 30.04.2020 75
2 2 31.01.2020 200
2 2 29.02.2020 150
2 4 31.03.2020 125
2 0 30.04.2020 230
3 1 31.01.2020 75
3 1 29.02.2020 65
3 3 31.03.2020 80
3 4 30.04.2020 90
4 0 31.01.2020 500
4 0 29.02.2020 350
4 1 31.03.2020 200
4 1 30.04.2020 100
;


options missing='0';
proc report data=have nowd  out=w;
    columns date code,amount total;
    define date/group;
    define code/across;
    define amount/analysis sum;
	define total/computed 'Total';
	compute total;
     total=sum(_c2_,_c3_,_c4_,_c5_,_c6_);
	endcomp;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Jul 2020 12:31:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668348#M79122</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-07-10T12:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate data and sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668351#M79123</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;, but the documentation clearly indicates you can put a statistic keyword in the COLUMNS statement. So the explicit calculation via a compute block shouldn't be necessary.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nevertheless, the code I posted a few minutes ago works only for SUM, I still can't get it to work for MEAN.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2020 12:35:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668351#M79123</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-10T12:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate data and sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668356#M79125</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nevertheless, the code I posted a few minutes ago works only for SUM, I still can't get it to work for MEAN.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Now it works with MEAN (and analogously for any other statistic SUM, P75, etc.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=sashelp.class;
    columns sex ("Age" age,height ("Average" height=heightmean));
    define sex/group;
    define age/across ' ';
    define height/analysis mean;
    define heightmean/analysis mean format=6.1;
run;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2020 12:57:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Aggregate-data-and-sum/m-p/668356#M79125</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-10T12:57:19Z</dc:date>
    </item>
  </channel>
</rss>

