<?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: Combining multiple rows of text into one in Proc sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-rows-of-text-into-one-in-Proc-sql/m-p/632164#M187396</link>
    <description>&lt;P&gt;Show us, in the form of a data step with sample data, both the BEFORE and AFTER datasets.&amp;nbsp; Help us help you.&lt;/P&gt;</description>
    <pubDate>Sat, 14 Mar 2020 16:57:20 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2020-03-14T16:57:20Z</dc:date>
    <item>
      <title>Combining multiple rows of text into one in Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-rows-of-text-into-one-in-Proc-sql/m-p/632161#M187393</link>
      <description>I know there is a way in Proc sql to combine multiple rows of a text field into one? I have tried a lot of the sql examples eg sum(), string_agg, xml for path. It all doesn’t seem to work. I can do this in base SAS but I need the code in sql.&lt;BR /&gt;&lt;BR /&gt;The data variables are id, date, orderno, line_order, result. ‘Result’ is the text field with multiple rows I need in one row and repeating id, orderno and date. The line_order variable gives the correct order of the rows in ascending. The lines can be as many as 30 rows of text. An id can occur multiple times but with a different orderno. Hope you can help me or point me in the right direction. Thanks!</description>
      <pubDate>Sat, 14 Mar 2020 16:38:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-rows-of-text-into-one-in-Proc-sql/m-p/632161#M187393</guid>
      <dc:creator>BrianC</dc:creator>
      <dc:date>2020-03-14T16:38:38Z</dc:date>
    </item>
    <item>
      <title>Re: Combining multiple rows of text into one in Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-rows-of-text-into-one-in-Proc-sql/m-p/632164#M187396</link>
      <description>&lt;P&gt;Show us, in the form of a data step with sample data, both the BEFORE and AFTER datasets.&amp;nbsp; Help us help you.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Mar 2020 16:57:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-rows-of-text-into-one-in-Proc-sql/m-p/632164#M187396</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-03-14T16:57:20Z</dc:date>
    </item>
    <item>
      <title>Re: Combining multiple rows of text into one in Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-rows-of-text-into-one-in-Proc-sql/m-p/632166#M187397</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Assuming&lt;/STRONG&gt; you are talking about collapsing multiple observations into a single observation and not just removing some embedded line break characters in a character value on one observation, then the answer is&amp;nbsp;&lt;STRONG&gt;No&lt;/STRONG&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why would you want to use PROC SQL for this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
do until (last.orderno);
  set have ;
  by id date orderno line_order ;
  length full_result $1000 ;
  full_result=catx(' ',full_result,result);
end;
  drop result ;
  rename line_order = number_of_lines ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Mar 2020 17:07:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-rows-of-text-into-one-in-Proc-sql/m-p/632166#M187397</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-14T17:07:11Z</dc:date>
    </item>
    <item>
      <title>Re: Combining multiple rows of text into one in Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-rows-of-text-into-one-in-Proc-sql/m-p/632168#M187399</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/316565"&gt;@BrianC&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Welcome to the community!&lt;/P&gt;
&lt;P&gt;I don't think such a function is available in PROC SQL for now:&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;&amp;nbsp;https://communities.sas.com/t5/SASware-Ballot-Ideas/Add-GROUP-CONCAT-function-to-proc-sql/idi-p/323092&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;As you mention, it will be easier using a data step.&lt;/P&gt;
&lt;P&gt;Could you please explain why this option is the only one for you?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Mar 2020 17:19:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-rows-of-text-into-one-in-Proc-sql/m-p/632168#M187399</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-03-14T17:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: Combining multiple rows of text into one in Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-rows-of-text-into-one-in-Proc-sql/m-p/632170#M187401</link>
      <description>Thank you for the rapid responses!&lt;BR /&gt;&lt;BR /&gt;The reason for sql is that the database is stored on teradata (over 30 mil obs) and so far every attempt to run a data step has taken so long that I have had to stop it. Proc sql (and sql in teradata studio) runs much more efficiently/faster. I am new to working with such large files and so if you have insight on how to work more efficiently with a data step over a teradata server, I am all for it. I am open to any solution that gets this done, efficiently! Thank you all again!</description>
      <pubDate>Sat, 14 Mar 2020 17:42:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-rows-of-text-into-one-in-Proc-sql/m-p/632170#M187401</guid>
      <dc:creator>BrianC</dc:creator>
      <dc:date>2020-03-14T17:42:23Z</dc:date>
    </item>
    <item>
      <title>Re: Combining multiple rows of text into one in Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-rows-of-text-into-one-in-Proc-sql/m-p/632171#M187402</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/316565"&gt;@BrianC&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you for the rapid responses!&lt;BR /&gt;&lt;BR /&gt;The reason for sql is that the database is stored on teradata (over 30 mil obs) and so far every attempt to run a data step has taken so long that I have had to stop it. Proc sql (and sql in teradata studio) runs much more efficiently/faster. I am new to working with such large files and so if you have insight on how to work more efficiently with a data step over a teradata server, I am all for it. I am open to any solution that gets this done, efficiently! Thank you all again!&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That is a different question, one that could be answered on a Teradata discussion forum.&lt;/P&gt;
&lt;P&gt;Just use pass-thru SQL to run whatever Teradata code you want.&amp;nbsp; Will have the advantage of only returning to SAS the set of data you need.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
connect to teradata ..... ;
create table want as select * from connection to teradata 
( ... put your Teradata code that uses Windowing Functions
   or Common Table Expressios (with keyword)
   or Recursion
   or other features that Teradata SQL supports 
 ...
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 14 Mar 2020 17:47:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-rows-of-text-into-one-in-Proc-sql/m-p/632171#M187402</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-14T17:47:28Z</dc:date>
    </item>
  </channel>
</rss>

