<?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: Adding/Merging Rows in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Adding-Merging-Rows/m-p/346878#M63594</link>
    <description>&lt;P&gt;alternatively proc sql&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 year_id, bat_id,sum(g) as g, sum(ab) as ab, sum(r) as r, sum(h) as h, sum(_2b) as _2b
from have group by year_id,bat_id;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 04 Apr 2017 01:34:46 GMT</pubDate>
    <dc:creator>Jagadishkatam</dc:creator>
    <dc:date>2017-04-04T01:34:46Z</dc:date>
    <item>
      <title>Adding/Merging Rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-Merging-Rows/m-p/346866#M63592</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my data, I have multiple rows for one person and I'd like to combine all the rows into one unique row while summing the values. For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8126i0D494ADAB416064B/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="combine.JPG" title="combine.JPG" align="right" /&gt;&lt;/P&gt;&lt;P&gt;Where year_id and bat_id are equal, I would like to combine the rows and sum the column values. So for 2015, I would just want one row with values:&lt;/P&gt;&lt;P&gt;&amp;nbsp;82 for G, 232 for AB, and so one. What procedure is best able to do this, or could it be done in the data step?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Justin&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 00:06:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-Merging-Rows/m-p/346866#M63592</guid>
      <dc:creator>jl1005</dc:creator>
      <dc:date>2017-04-04T00:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: Adding/Merging Rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-Merging-Rows/m-p/346876#M63593</link>
      <description>&lt;P&gt;you could try the proc means&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input year_id 	bat_id$	g	ab	r	h	_2b;
cards;
2015	almoa001	51	178	30	47	9
2015	almoa001	31	54	6	11	3
2014	almoa001	32	98	9	26	5
2014	almoa001	27	106	10	21	5
;


proc means data=have nway;
class year_id bat_id;
var g ab r h _2b;
output out=sums sum=/autoname;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 01:23:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-Merging-Rows/m-p/346876#M63593</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-04-04T01:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: Adding/Merging Rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-Merging-Rows/m-p/346878#M63594</link>
      <description>&lt;P&gt;alternatively proc sql&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 year_id, bat_id,sum(g) as g, sum(ab) as ab, sum(r) as r, sum(h) as h, sum(_2b) as _2b
from have group by year_id,bat_id;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Apr 2017 01:34:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-Merging-Rows/m-p/346878#M63594</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-04-04T01:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: Adding/Merging Rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-Merging-Rows/m-p/347058#M63605</link>
      <description>&lt;P&gt;If you use &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12151"&gt;@Jagadishkatam&lt;/a&gt;'s Proc Means solution with &lt;FONT color="#008000"&gt;Sum=&lt;/FONT&gt; instead of &lt;FONT color="#008000"&gt;Sum= / autoname &lt;FONT color="#000000"&gt;then the variable names would stay unchanged if that would be the preferred behavior.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 14:48:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-Merging-Rows/m-p/347058#M63605</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-04T14:48:17Z</dc:date>
    </item>
  </channel>
</rss>

