<?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 Combine rows of data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Combine-rows-of-data/m-p/295190#M61666</link>
    <description>&lt;P&gt;I have a dataset like below:&lt;/P&gt;
&lt;P&gt;Subj &amp;nbsp; C1 &amp;nbsp; &amp;nbsp;C2&lt;/P&gt;
&lt;P&gt;S01 &amp;nbsp; &amp;nbsp;Y &amp;nbsp; &amp;nbsp; &amp;nbsp;N&lt;/P&gt;
&lt;P&gt;S01 &amp;nbsp; &amp;nbsp;N &amp;nbsp; &amp;nbsp; &amp;nbsp;N&lt;/P&gt;
&lt;P&gt;S02 &amp;nbsp; &amp;nbsp;Y &amp;nbsp; &amp;nbsp; &amp;nbsp;N&lt;/P&gt;
&lt;P&gt;S02 &amp;nbsp; &amp;nbsp;N &amp;nbsp; &amp;nbsp; &amp;nbsp;Y&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to combine the rows with distinct Subjs as below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Subj &amp;nbsp; C1 &amp;nbsp; &amp;nbsp;C2&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;S01 &amp;nbsp; &amp;nbsp;Y &amp;nbsp; &amp;nbsp; &amp;nbsp;N&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;S02 &amp;nbsp; &amp;nbsp;Y &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;Y&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;How should I go about it, please?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Thank you for your help in advance!&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Aug 2016 14:29:06 GMT</pubDate>
    <dc:creator>zz</dc:creator>
    <dc:date>2016-08-30T14:29:06Z</dc:date>
    <item>
      <title>Combine rows of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-rows-of-data/m-p/295190#M61666</link>
      <description>&lt;P&gt;I have a dataset like below:&lt;/P&gt;
&lt;P&gt;Subj &amp;nbsp; C1 &amp;nbsp; &amp;nbsp;C2&lt;/P&gt;
&lt;P&gt;S01 &amp;nbsp; &amp;nbsp;Y &amp;nbsp; &amp;nbsp; &amp;nbsp;N&lt;/P&gt;
&lt;P&gt;S01 &amp;nbsp; &amp;nbsp;N &amp;nbsp; &amp;nbsp; &amp;nbsp;N&lt;/P&gt;
&lt;P&gt;S02 &amp;nbsp; &amp;nbsp;Y &amp;nbsp; &amp;nbsp; &amp;nbsp;N&lt;/P&gt;
&lt;P&gt;S02 &amp;nbsp; &amp;nbsp;N &amp;nbsp; &amp;nbsp; &amp;nbsp;Y&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to combine the rows with distinct Subjs as below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Subj &amp;nbsp; C1 &amp;nbsp; &amp;nbsp;C2&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;S01 &amp;nbsp; &amp;nbsp;Y &amp;nbsp; &amp;nbsp; &amp;nbsp;N&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;S02 &amp;nbsp; &amp;nbsp;Y &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;Y&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;How should I go about it, please?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Thank you for your help in advance!&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 14:29:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-rows-of-data/m-p/295190#M61666</guid>
      <dc:creator>zz</dc:creator>
      <dc:date>2016-08-30T14:29:06Z</dc:date>
    </item>
    <item>
      <title>Re: Combine rows of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-rows-of-data/m-p/295194#M61667</link>
      <description>&lt;P&gt;If I understand right, Y has precedence over N?&lt;/P&gt;
&lt;P&gt;If those were 1 and 0 respectively (and you could have Y and N as a SAS format instead&amp;nbsp;for display purposes), you could use the max() SQL aggregate&amp;nbsp;function.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 14:32:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-rows-of-data/m-p/295194#M61667</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-08-30T14:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: Combine rows of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-rows-of-data/m-p/295201#M61669</link>
      <description>&lt;P&gt;Actually, the SAS implementation of SQL permits using the MAX function on character fields:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table want as select Subj, max(C1) as C1, max(C2) as C2 &lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;, count(*) as nrows&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;from have&lt;/P&gt;
&lt;P&gt;group by subj;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 17:36:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-rows-of-data/m-p/295201#M61669</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-08-30T17:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: Combine rows of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-rows-of-data/m-p/295202#M61670</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data C;
   input (Subj   C1    C2)($);
   cards;
S01    Y      N
S01    N      N
S02    Y      N
S02    N      Y
;;;;
   run;
proc print;
   run;
proc summary data=c nway;
   class subj;
   output out=temp 
      idgroup(max(c1) out(c1)=)
      idgroup(max(c2) out(c2)=)
      ;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Aug 2016 14:47:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-rows-of-data/m-p/295202#M61670</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-08-30T14:47:19Z</dc:date>
    </item>
    <item>
      <title>Re: Combine rows of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-rows-of-data/m-p/295259#M61687</link>
      <description>&lt;P&gt;There is one additional detail: I need to count the number of rows for each subject, while combining rows. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your below implementation! &amp;nbsp;It is exactly what I'd need. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 17:15:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-rows-of-data/m-p/295259#M61687</guid>
      <dc:creator>zz</dc:creator>
      <dc:date>2016-08-30T17:15:41Z</dc:date>
    </item>
  </channel>
</rss>

