<?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 PROC SQL: GROUP_CONCAT in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-GROUP-CONCAT/m-p/35491#M8765</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;See if the response provided in the following post answers your question:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.rhinocerus.net/forum/soft-sys-sas/485907-re-simulating-group_concat-sql-agregate-function.html"&gt;http://www.rhinocerus.net/forum/soft-sys-sas/485907-re-simulating-group_concat-sql-agregate-function.html&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Jul 2011 15:40:19 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2011-07-22T15:40:19Z</dc:date>
    <item>
      <title>PROC SQL: GROUP_CONCAT</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-GROUP-CONCAT/m-p/35490#M8764</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;﻿Is there a equivalent function to MySQL's "group_concat" in SAS PROC SQL? I would like concatenate multiple associated rows into a composite key. There is no max/min limit to the number of rows. As such, transposing this field into columns may not be appropriate. Group_concat would allow me to avoid additional data/code manipulation with each change to the query.&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jul 2011 15:31:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-GROUP-CONCAT/m-p/35490#M8764</guid>
      <dc:creator>Brian</dc:creator>
      <dc:date>2011-07-22T15:31:24Z</dc:date>
    </item>
    <item>
      <title>PROC SQL: GROUP_CONCAT</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-GROUP-CONCAT/m-p/35491#M8765</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;See if the response provided in the following post answers your question:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.rhinocerus.net/forum/soft-sys-sas/485907-re-simulating-group_concat-sql-agregate-function.html"&gt;http://www.rhinocerus.net/forum/soft-sys-sas/485907-re-simulating-group_concat-sql-agregate-function.html&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jul 2011 15:40:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-GROUP-CONCAT/m-p/35491#M8765</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-07-22T15:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL: GROUP_CONCAT</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-GROUP-CONCAT/m-p/329664#M62551</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I create a function&amp;nbsp;sql_query_concat , maybe you can use&amp;nbsp;like &amp;nbsp;mysql group_concat with something different&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select x , y group_concat( z )&amp;nbsp;&lt;/P&gt;&lt;P&gt;from test_monotonic&lt;/P&gt;&lt;P&gt;group by x ,y&amp;nbsp;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* demo data create */&lt;BR /&gt;data test_monotonic;&lt;BR /&gt;length x $3. ;&lt;BR /&gt;length y $1. ;&lt;BR /&gt;x = "a" ; y = "b" ; z = 3 ; output ;&lt;BR /&gt;x = "a" ; y = "b" ; z = 1 ; output ;&lt;BR /&gt;x = "aa" ; y = "b" ; z = 3 ; output ;&lt;BR /&gt;x = "aa" ; y = "b" ; z = 2 ; output ;&lt;BR /&gt;x = "aaa" ; y = "b" ; z = 3 ; output ;&lt;BR /&gt;x = "aaa" ; y = "b" ; z = 3 ; output ;&lt;BR /&gt;run ;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/* pass sql command (sql_cmd ) as parameter and concat the result with optional delimiter parameter (DLM) */&lt;BR /&gt;%macro sql_query_concat( sql_cmd ,DLM=%str(,), OUT=qry_result ) ;&lt;BR /&gt;%local qry_table ;&lt;BR /&gt;%global &amp;amp;OUT. ;&lt;BR /&gt;%let sql_cmd = %qsysfunc( dequote( &amp;amp;sql_cmd. ) ) ;&lt;BR /&gt;%let qry_table = sqlQuery%substr(%sysfunc(compress( %sysfunc(time())*%sysfunc(ranuni(32767))*100)) ,1,5 ) ;&lt;BR /&gt;proc sql noprint;&lt;BR /&gt;create table &amp;amp;qry_table. as&lt;BR /&gt;%unquote( &amp;amp;sql_cmd. )&lt;BR /&gt;;&lt;BR /&gt;select *&lt;BR /&gt;into : &amp;amp;OUT. separated by "&amp;amp;DLM."&lt;BR /&gt;from &amp;amp;qry_table.&lt;BR /&gt;;&lt;BR /&gt;drop table &amp;amp;qry_table.&lt;BR /&gt;;&lt;BR /&gt;quit ;&lt;BR /&gt;%mend ;&lt;BR /&gt;/* for run_macro usage */&lt;BR /&gt;%macro Fsql_query_concat() ;&lt;BR /&gt;%let sql_cmd = %qsysfunc(dequote( &amp;amp;sql_cmd. ) ) ;&lt;BR /&gt;%let DLM = %qsysfunc( dequote( &amp;amp;DLM. ) ) ;&lt;BR /&gt;%sql_query_concat( &amp;amp;sql_cmd. ,DLM=&amp;amp;DLM., OUT=OUTF )&lt;BR /&gt;%mend ;&lt;BR /&gt;/* create function version of macro sql_query_concat */&lt;BR /&gt;proc fcmp outlib=work.func.tmp;&lt;BR /&gt;function sql_query_concat( sql_cmd $ , DLM $ ) $ ;&lt;BR /&gt;LENGTH OUTF $256 ;&lt;BR /&gt;rc = run_macro( 'Fsql_query_concat' , sql_cmd ,DLM ,OUTF ) ;&lt;BR /&gt;return(OUTF);&lt;BR /&gt;endsub ;&lt;BR /&gt;quit ;&lt;BR /&gt;options cmplib=work.func ;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*by determined the column x and y , concat the records into a string */&lt;BR /&gt;proc sql ;&lt;BR /&gt;select distinct x , y ,sql_query_concat("select z from test_monotonic where x = '"|| test_monotonic.x || "' and y = '" || test_monotonic.y || "'", ",")&lt;BR /&gt;from test_monotonic&lt;BR /&gt;;&lt;BR /&gt;quit ;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2017 02:57:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-GROUP-CONCAT/m-p/329664#M62551</guid>
      <dc:creator>andywang</dc:creator>
      <dc:date>2017-02-03T02:57:13Z</dc:date>
    </item>
  </channel>
</rss>

