<?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: Group Concat and Counting in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Group-Concat-and-Counting/m-p/417057#M102422</link>
    <description>&lt;P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data PLATFORMS;
input ORDERID $ PLATFORM $;
CARDS;
A ZXO
B ZXO
C EXP
D ZXO
D EXP
;
run;

data want;
length list $ 200;
 do n=1 by 1 until(last.ORDERID);
   set PLATFORMS;
   by  ORDERID;
   list=catx(' ',list,PLATFORM);
 end;
 list=cats('"',list,'"');
 keep list n;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR data-mce-bogus="1" /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Nov 2017 14:12:29 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2017-11-29T14:12:29Z</dc:date>
    <item>
      <title>Group Concat and Counting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-Concat-and-Counting/m-p/416773#M102354</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to do the MYSQL of Groupconcat and also I would like to count the number of&amp;nbsp;occurrences.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far I got this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data PLATFORMS;

input ORDERID $ PLATFORM $;
CARDS;

A ZXO
B ZXO
C EXP
D ZXO
D EXP
;
run;

data INVOLVED_PLATFORMS (drop=PLATFORM_old);
set PLATFORMS (rename=(PLATFORM=PLATFORM_old));
by ORDERID;
retain PLATFORM;
length PLATFORM $ 64;
if first.ORDERID then PLATFORM = '';
PLATFORM = catx(' ',trim(PLATFORM),PLATFORM_old);
if first.ORDERID then count = 0;
count = count + 1;
if last.ORDERID then output;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I think I am halfway there, but I cant figure out why count is empty in the 4th row. It should be "2".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dirk&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 17:19:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-Concat-and-Counting/m-p/416773#M102354</guid>
      <dc:creator>dirks</dc:creator>
      <dc:date>2017-11-28T17:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: Group Concat and Counting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-Concat-and-Counting/m-p/416774#M102355</link>
      <description>Retaining count could help.</description>
      <pubDate>Tue, 28 Nov 2017 17:28:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-Concat-and-Counting/m-p/416774#M102355</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2017-11-28T17:28:10Z</dc:date>
    </item>
    <item>
      <title>Re: Group Concat and Counting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-Concat-and-Counting/m-p/416782#M102357</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/101884"&gt;@dirks&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I would like to do the MYSQL of Groupconcat and also I would like to count the number of&amp;nbsp;occurrences.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is that? Can you show an example of the output you'd like? In general, it's not a good idea to try and do 'exact' conversions, it's better to explain a problem and use a SAS type solution instead.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 17:39:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-Concat-and-Counting/m-p/416782#M102357</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-28T17:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: Group Concat and Counting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-Concat-and-Counting/m-p/416793#M102358</link>
      <description>&lt;P&gt;This has been proposed as an enhancement to SAS\SQL, see (and vote!) :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SASware-Ballot-Ideas/Add-GROUP-CONCAT-function-to-proc-sql/idi-p/323092" target="_self"&gt;https://communities.sas.com/t5/SASware-Ballot-Ideas/Add-GROUP-CONCAT-function-to-proc-sql/idi-p/323092&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 18:05:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-Concat-and-Counting/m-p/416793#M102358</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-11-28T18:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: Group Concat and Counting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-Concat-and-Counting/m-p/416907#M102390</link>
      <description>&lt;P&gt;I have this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;A ZXO
B ZXO
C EXP
D ZXO
D EXP
E XXX
E YYY
E ZZZ&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;And I want this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;A "ZXO" 1
B "ZXO" 1
C "EXP" 1
D "ZXO EXP" 2
E "XXX YYY ZZZ" 3&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;I want to group by the 1st column, concat all strings of the 2nd column and count the records per 1st colum as a new 3rd column.&lt;BR /&gt;&lt;BR /&gt;In SQL you would to this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SELECT
Column1,
GROUPCONCAT(" ", Column2),
COUNT(Column1)
FROM
DATASET
GROUP BY Column1;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Nov 2017 22:39:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-Concat-and-Counting/m-p/416907#M102390</guid>
      <dc:creator>dirks</dc:creator>
      <dc:date>2017-11-28T22:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: Group Concat and Counting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-Concat-and-Counting/m-p/417057#M102422</link>
      <description>&lt;P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data PLATFORMS;
input ORDERID $ PLATFORM $;
CARDS;
A ZXO
B ZXO
C EXP
D ZXO
D EXP
;
run;

data want;
length list $ 200;
 do n=1 by 1 until(last.ORDERID);
   set PLATFORMS;
   by  ORDERID;
   list=catx(' ',list,PLATFORM);
 end;
 list=cats('"',list,'"');
 keep list n;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR data-mce-bogus="1" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2017 14:12:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-Concat-and-Counting/m-p/417057#M102422</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-29T14:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: Group Concat and Counting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-Concat-and-Counting/m-p/417345#M102518</link>
      <description>Thank you very much. I will use this one for future projects.</description>
      <pubDate>Thu, 30 Nov 2017 09:49:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-Concat-and-Counting/m-p/417345#M102518</guid>
      <dc:creator>dirks</dc:creator>
      <dc:date>2017-11-30T09:49:34Z</dc:date>
    </item>
  </channel>
</rss>

