<?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: Sum amount with multiple rows in to one row in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sum-amount-with-multiple-rows-in-to-one-row/m-p/458267#M116265</link>
    <description>&lt;P&gt;Thank you so much.&lt;/P&gt;</description>
    <pubDate>Fri, 27 Apr 2018 21:44:14 GMT</pubDate>
    <dc:creator>BonnaryW</dc:creator>
    <dc:date>2018-04-27T21:44:14Z</dc:date>
    <item>
      <title>Sum amount with multiple rows in to one row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-amount-with-multiple-rows-in-to-one-row/m-p/458254#M116258</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to add up the AMOUNT AND INCREASE with multiple rows have the same ID.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data calc;&lt;/P&gt;&lt;P&gt;input ID AMOUNT INCREASE&lt;/P&gt;&lt;P&gt;cards;&lt;BR /&gt;8888&amp;nbsp;&amp;nbsp; 50&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;3.55&lt;BR /&gt;8889&amp;nbsp;&amp;nbsp; 1.10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;0&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;8889&amp;nbsp;&amp;nbsp; 2.99&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;2.22&lt;BR /&gt;8890&amp;nbsp;&amp;nbsp; 3.48&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;15&lt;BR /&gt;8891&amp;nbsp;&amp;nbsp; 34.08&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;1&amp;nbsp;&amp;nbsp;&lt;BR /&gt;8891&amp;nbsp;&amp;nbsp; 144.87&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;BR /&gt;8891&amp;nbsp;&amp;nbsp; 2.24&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.8&lt;BR /&gt;8892&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;I like to add the AMOUNT AND INCREASE FOR EACH ID.&lt;/P&gt;&lt;P&gt;The result:&lt;/P&gt;&lt;P&gt;8888&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;50 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3.55&lt;BR /&gt;8889&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;4.09&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.22&lt;BR /&gt;8890&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; 3.48&amp;nbsp;&amp;nbsp;&amp;nbsp; 15&lt;BR /&gt;8891&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 181.19&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;5.8&lt;BR /&gt;8892&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 20:28:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-amount-with-multiple-rows-in-to-one-row/m-p/458254#M116258</guid>
      <dc:creator>BonnaryW</dc:creator>
      <dc:date>2018-04-27T20:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: Sum amount with multiple rows in to one row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-amount-with-multiple-rows-in-to-one-row/m-p/458257#M116259</link>
      <description>&lt;P&gt;Summarizing data is straightforward with grouping variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an example of two ways to do this, with different output styles. 2 tables are created, want and want2 with different structures, I think you're looking for WANT1 perhaps?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Create summary statistics for a dataset by a 'grouping' variable and store it in a dataset;

*Generate sample fake data;
data have;
	input ID          feature1         feature2         feature3;
	cards;
1               7.72               5.43              4.35
1               5.54               2.25              8.22 
1               4.43               6.75              2.22
1               3.22               3.21              7.31
2               6.72               2.86              6.11
2               5.89               4.25              5.25 
2               3.43               7.30              8.21
2               1.22               3.55              6.55

;
run;

*Create summary data;
proc means data=have noprint;
	by id;
	var feature1-feature3;
	output out=want median= var= mean= /autoname;
run;

*Show for display;
proc print data=want;
run;

*First done here:https://communities.sas.com/t5/General-SAS-Programming/Getting-creating-new-summary-variables-longitudinal-data/m-p/347940/highlight/false#M44842;
*Another way to present data is as follows;

proc means data=have stackods nway n min max mean median std p5 p95;
    by id;
    var feature1-feature3;
    ods output summary=want2;
run;

*Show for display;
proc print data=want2;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Apr 2018 20:37:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-amount-with-multiple-rows-in-to-one-row/m-p/458257#M116259</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-04-27T20:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: Sum amount with multiple rows in to one row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-amount-with-multiple-rows-in-to-one-row/m-p/458258#M116260</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data calc;

input ID AMOUNT INCREASE;

cards;
8888   50              3.55
8889   1.10           0   
8889   2.99           2.22
8890   3.48         15
8891   34.08       1  
8891   144.87     4
8891   2.24        0.8
8892   0             0 
;

proc sql;
create table want as
select id,sum(AMOUNT) as sum_amt, sum(increase) as sum_increase
from calc
group by id;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Apr 2018 20:38:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-amount-with-multiple-rows-in-to-one-row/m-p/458258#M116260</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-04-27T20:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: Sum amount with multiple rows in to one row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-amount-with-multiple-rows-in-to-one-row/m-p/458266#M116264</link>
      <description>&lt;P&gt;thank you so much.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 21:43:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-amount-with-multiple-rows-in-to-one-row/m-p/458266#M116264</guid>
      <dc:creator>BonnaryW</dc:creator>
      <dc:date>2018-04-27T21:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: Sum amount with multiple rows in to one row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-amount-with-multiple-rows-in-to-one-row/m-p/458267#M116265</link>
      <description>&lt;P&gt;Thank you so much.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 21:44:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-amount-with-multiple-rows-in-to-one-row/m-p/458267#M116265</guid>
      <dc:creator>BonnaryW</dc:creator>
      <dc:date>2018-04-27T21:44:14Z</dc:date>
    </item>
  </channel>
</rss>

