<?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 Concatenate multiple rows of free text grouped by an ID? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-rows-of-free-text-grouped-by-an-ID/m-p/837462#M331112</link>
    <description>&lt;P&gt;Attached I have a dataset of orders with columns of free text with some containing multiple lines.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to concatenate the rows, grouping by the ORDER_ID. I looked at this post,&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-rows-into-a-single-value/td-p/132882" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-rows-into-a-single-value/td-p/132882&lt;/A&gt;&amp;nbsp; but it's not concatenating how I want. The records are already in order by LINE where applicable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data orders;&lt;BR /&gt;infile datalines delimiter=','; &lt;BR /&gt;input ORDER_ID NOTE_CSN_ID TEXT $ LINE;&lt;BR /&gt;datalines;&lt;BR /&gt;1011533,44561,apple,1&lt;BR /&gt;1011536,44562,apple,1&lt;BR /&gt;1011536,44562,orange,2&lt;BR /&gt;1058001,44563,apple,1&lt;BR /&gt;1058001,44563,banana,2&lt;BR /&gt;1011569,44564,apple,1&lt;BR /&gt;1011569,44564,peanut,2&lt;BR /&gt;1011569,44564,pear,3&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have:&lt;/P&gt;
&lt;TABLE class="jiveBorder" border="1" width="368px"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH valign="middle" width="86.4844px" height="19px"&gt;ORDER_ID&lt;/TH&gt;
&lt;TH valign="middle" width="91.5469px" height="19px"&gt;NOTE_CSN_ID&lt;/TH&gt;
&lt;TH width="94.625px" height="19px"&gt;TEXT&lt;/TH&gt;
&lt;TH width="94.3438px"&gt;LINE&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR style="height: 16.0pt;"&gt;
&lt;TD width="86.4844px" height="16px" align="right" style="height: 16.0pt; width: 65pt;"&gt;1011533&lt;/TD&gt;
&lt;TD width="91.5469px" height="16px" align="right" style="height: 16.0pt; width: 65pt;"&gt;44561&lt;/TD&gt;
&lt;TD width="94.625px" height="16px"&gt;apple&lt;/TD&gt;
&lt;TD width="94.3438px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 16.0pt;"&gt;
&lt;TD width="86.4844px" height="16px" align="right" style="height: 16.0pt; width: 65pt;"&gt;1011536&lt;/TD&gt;
&lt;TD width="91.5469px" height="16px"&gt;44562&lt;/TD&gt;
&lt;TD width="94.625px" height="16px"&gt;apple&lt;/TD&gt;
&lt;TD width="94.3438px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 16.0pt;"&gt;
&lt;TD width="86.4844px" height="16px" align="right" style="height: 16.0pt; width: 65pt;"&gt;1011536&lt;/TD&gt;
&lt;TD width="91.5469px" height="16px"&gt;44562&lt;/TD&gt;
&lt;TD width="94.625px" height="16px"&gt;orange&lt;/TD&gt;
&lt;TD width="94.3438px"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 16.0pt;"&gt;
&lt;TD width="86.4844px" height="21" align="right" style="height: 16.0pt; width: 65pt;"&gt;1058001&lt;/TD&gt;
&lt;TD width="91.5469px" height="30px"&gt;44563&lt;/TD&gt;
&lt;TD width="94.625px" height="30px"&gt;apple&lt;/TD&gt;
&lt;TD width="94.3438px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 16.0pt;"&gt;
&lt;TD width="86.4844px" height="21" align="right" style="height: 16.0pt; width: 65pt;"&gt;1058001&lt;/TD&gt;
&lt;TD width="91.5469px" height="30px"&gt;44563&lt;/TD&gt;
&lt;TD width="94.625px" height="30px"&gt;banana&lt;/TD&gt;
&lt;TD width="94.3438px"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 16.0pt;"&gt;
&lt;TD width="86.4844px" height="21" align="right" style="height: 16.0pt; width: 65pt;"&gt;1011569&lt;/TD&gt;
&lt;TD width="91.5469px" height="30px"&gt;44564&lt;/TD&gt;
&lt;TD width="94.625px" height="30px"&gt;apple&lt;/TD&gt;
&lt;TD width="94.3438px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 16.0pt;"&gt;
&lt;TD width="86.4844px" height="21" align="right" style="height: 16.0pt; width: 65pt;"&gt;1011569&lt;/TD&gt;
&lt;TD width="91.5469px"&gt;44564&lt;/TD&gt;
&lt;TD width="94.625px"&gt;peanut&lt;/TD&gt;
&lt;TD width="94.3438px"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 16.0pt;"&gt;
&lt;TD width="86.4844px" height="21" align="right" style="height: 16.0pt; width: 65pt;"&gt;1011569&lt;/TD&gt;
&lt;TD width="91.5469px"&gt;44564&lt;/TD&gt;
&lt;TD width="94.625px"&gt;pear&lt;/TD&gt;
&lt;TD width="94.3438px"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Want:&lt;/P&gt;
&lt;TABLE border="1" width="51.3745704467354%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="10.73883161512028%" height="30px"&gt;ORDER_ID&lt;/TD&gt;
&lt;TD width="18.6426116838488%" height="30px"&gt;NOTE_CSN_ID&lt;/TD&gt;
&lt;TD width="21.993127147766337%" height="30px"&gt;TEXT&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="10.73883161512028%" height="30px"&gt;1011533&lt;/TD&gt;
&lt;TD width="18.6426116838488%" height="30px"&gt;44561&lt;/TD&gt;
&lt;TD width="21.993127147766337%" height="30px"&gt;apple&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="10.73883161512028%" height="30px"&gt;1011536&lt;/TD&gt;
&lt;TD width="18.6426116838488%" height="30px"&gt;44562&lt;/TD&gt;
&lt;TD width="21.993127147766337%" height="30px"&gt;apple, orange&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="10.73883161512028%" height="30px"&gt;1058001&lt;/TD&gt;
&lt;TD width="18.6426116838488%" height="30px"&gt;44563&lt;/TD&gt;
&lt;TD width="21.993127147766337%" height="30px"&gt;apple,&amp;nbsp;banana&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="10.73883161512028%" height="30px"&gt;1011569&lt;/TD&gt;
&lt;TD width="18.6426116838488%" height="30px"&gt;44564&lt;/TD&gt;
&lt;TD width="21.993127147766337%" height="30px"&gt;apple, peanut, pear&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Fri, 07 Oct 2022 21:25:53 GMT</pubDate>
    <dc:creator>PharmlyDoc</dc:creator>
    <dc:date>2022-10-07T21:25:53Z</dc:date>
    <item>
      <title>Concatenate multiple rows of free text grouped by an ID?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-rows-of-free-text-grouped-by-an-ID/m-p/837462#M331112</link>
      <description>&lt;P&gt;Attached I have a dataset of orders with columns of free text with some containing multiple lines.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to concatenate the rows, grouping by the ORDER_ID. I looked at this post,&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-rows-into-a-single-value/td-p/132882" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-rows-into-a-single-value/td-p/132882&lt;/A&gt;&amp;nbsp; but it's not concatenating how I want. The records are already in order by LINE where applicable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data orders;&lt;BR /&gt;infile datalines delimiter=','; &lt;BR /&gt;input ORDER_ID NOTE_CSN_ID TEXT $ LINE;&lt;BR /&gt;datalines;&lt;BR /&gt;1011533,44561,apple,1&lt;BR /&gt;1011536,44562,apple,1&lt;BR /&gt;1011536,44562,orange,2&lt;BR /&gt;1058001,44563,apple,1&lt;BR /&gt;1058001,44563,banana,2&lt;BR /&gt;1011569,44564,apple,1&lt;BR /&gt;1011569,44564,peanut,2&lt;BR /&gt;1011569,44564,pear,3&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have:&lt;/P&gt;
&lt;TABLE class="jiveBorder" border="1" width="368px"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH valign="middle" width="86.4844px" height="19px"&gt;ORDER_ID&lt;/TH&gt;
&lt;TH valign="middle" width="91.5469px" height="19px"&gt;NOTE_CSN_ID&lt;/TH&gt;
&lt;TH width="94.625px" height="19px"&gt;TEXT&lt;/TH&gt;
&lt;TH width="94.3438px"&gt;LINE&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR style="height: 16.0pt;"&gt;
&lt;TD width="86.4844px" height="16px" align="right" style="height: 16.0pt; width: 65pt;"&gt;1011533&lt;/TD&gt;
&lt;TD width="91.5469px" height="16px" align="right" style="height: 16.0pt; width: 65pt;"&gt;44561&lt;/TD&gt;
&lt;TD width="94.625px" height="16px"&gt;apple&lt;/TD&gt;
&lt;TD width="94.3438px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 16.0pt;"&gt;
&lt;TD width="86.4844px" height="16px" align="right" style="height: 16.0pt; width: 65pt;"&gt;1011536&lt;/TD&gt;
&lt;TD width="91.5469px" height="16px"&gt;44562&lt;/TD&gt;
&lt;TD width="94.625px" height="16px"&gt;apple&lt;/TD&gt;
&lt;TD width="94.3438px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 16.0pt;"&gt;
&lt;TD width="86.4844px" height="16px" align="right" style="height: 16.0pt; width: 65pt;"&gt;1011536&lt;/TD&gt;
&lt;TD width="91.5469px" height="16px"&gt;44562&lt;/TD&gt;
&lt;TD width="94.625px" height="16px"&gt;orange&lt;/TD&gt;
&lt;TD width="94.3438px"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 16.0pt;"&gt;
&lt;TD width="86.4844px" height="21" align="right" style="height: 16.0pt; width: 65pt;"&gt;1058001&lt;/TD&gt;
&lt;TD width="91.5469px" height="30px"&gt;44563&lt;/TD&gt;
&lt;TD width="94.625px" height="30px"&gt;apple&lt;/TD&gt;
&lt;TD width="94.3438px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 16.0pt;"&gt;
&lt;TD width="86.4844px" height="21" align="right" style="height: 16.0pt; width: 65pt;"&gt;1058001&lt;/TD&gt;
&lt;TD width="91.5469px" height="30px"&gt;44563&lt;/TD&gt;
&lt;TD width="94.625px" height="30px"&gt;banana&lt;/TD&gt;
&lt;TD width="94.3438px"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 16.0pt;"&gt;
&lt;TD width="86.4844px" height="21" align="right" style="height: 16.0pt; width: 65pt;"&gt;1011569&lt;/TD&gt;
&lt;TD width="91.5469px" height="30px"&gt;44564&lt;/TD&gt;
&lt;TD width="94.625px" height="30px"&gt;apple&lt;/TD&gt;
&lt;TD width="94.3438px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 16.0pt;"&gt;
&lt;TD width="86.4844px" height="21" align="right" style="height: 16.0pt; width: 65pt;"&gt;1011569&lt;/TD&gt;
&lt;TD width="91.5469px"&gt;44564&lt;/TD&gt;
&lt;TD width="94.625px"&gt;peanut&lt;/TD&gt;
&lt;TD width="94.3438px"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 16.0pt;"&gt;
&lt;TD width="86.4844px" height="21" align="right" style="height: 16.0pt; width: 65pt;"&gt;1011569&lt;/TD&gt;
&lt;TD width="91.5469px"&gt;44564&lt;/TD&gt;
&lt;TD width="94.625px"&gt;pear&lt;/TD&gt;
&lt;TD width="94.3438px"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Want:&lt;/P&gt;
&lt;TABLE border="1" width="51.3745704467354%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="10.73883161512028%" height="30px"&gt;ORDER_ID&lt;/TD&gt;
&lt;TD width="18.6426116838488%" height="30px"&gt;NOTE_CSN_ID&lt;/TD&gt;
&lt;TD width="21.993127147766337%" height="30px"&gt;TEXT&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="10.73883161512028%" height="30px"&gt;1011533&lt;/TD&gt;
&lt;TD width="18.6426116838488%" height="30px"&gt;44561&lt;/TD&gt;
&lt;TD width="21.993127147766337%" height="30px"&gt;apple&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="10.73883161512028%" height="30px"&gt;1011536&lt;/TD&gt;
&lt;TD width="18.6426116838488%" height="30px"&gt;44562&lt;/TD&gt;
&lt;TD width="21.993127147766337%" height="30px"&gt;apple, orange&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="10.73883161512028%" height="30px"&gt;1058001&lt;/TD&gt;
&lt;TD width="18.6426116838488%" height="30px"&gt;44563&lt;/TD&gt;
&lt;TD width="21.993127147766337%" height="30px"&gt;apple,&amp;nbsp;banana&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="10.73883161512028%" height="30px"&gt;1011569&lt;/TD&gt;
&lt;TD width="18.6426116838488%" height="30px"&gt;44564&lt;/TD&gt;
&lt;TD width="21.993127147766337%" height="30px"&gt;apple, peanut, pear&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2022 21:25:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-rows-of-free-text-grouped-by-an-ID/m-p/837462#M331112</guid>
      <dc:creator>PharmlyDoc</dc:creator>
      <dc:date>2022-10-07T21:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate multiple rows of free text grouped by an ID?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-rows-of-free-text-grouped-by-an-ID/m-p/837465#M331113</link>
      <description>&lt;P&gt;There are multiple different solutions in that linked thread, any of which should work for you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Can you please post the code attempted that does not work and explain how it did not work? If those solutions do not work, it's possible there's something in the data that necessitates a different type of solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: here's my referenced example on this type of problem&amp;nbsp;&lt;A href="https://gist.github.com/statgeek/d583cfa992bf56da51d435165b07e96a" target="_blank"&gt;https://gist.github.com/statgeek/d583cfa992bf56da51d435165b07e96a&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2022 21:33:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-rows-of-free-text-grouped-by-an-ID/m-p/837465#M331113</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-10-07T21:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate multiple rows of free text grouped by an ID?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-rows-of-free-text-grouped-by-an-ID/m-p/837466#M331114</link>
      <description>&lt;P&gt;Perhaps there is something wrong with my data. The dataset that I am applying this approach has "TEXT" column cells containing as many as 2000 characters.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data orders_grouped;&lt;BR /&gt;retain ORDER_ID NOTE_CSN_ID TEXT;&lt;BR /&gt;length cat $30.;&lt;BR /&gt;do until (last.ORDER_ID);&lt;BR /&gt;set orders;&lt;BR /&gt;by ORDER_ID NOTE_CSN_ID LINE notsorted;&lt;BR /&gt;cat=catx(',',cat,TEXT);&lt;BR /&gt;end;&lt;BR /&gt;drop TEXT LINE;&lt;BR /&gt;rename cat=TEXT;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2022 21:35:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-rows-of-free-text-grouped-by-an-ID/m-p/837466#M331114</guid>
      <dc:creator>PharmlyDoc</dc:creator>
      <dc:date>2022-10-07T21:35:30Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate multiple rows of free text grouped by an ID?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-rows-of-free-text-grouped-by-an-ID/m-p/837468#M331116</link>
      <description>&lt;PRE&gt;length cat $30.;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The length of the final variable to is set to be 30 but each row can have as many as 2000 characters? The length is too short and the variable is being truncated to the first 30 characters only.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you need LINE unsorted in your BY statement? I doubt it will change things but just something I noticed.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2022 21:44:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-rows-of-free-text-grouped-by-an-ID/m-p/837468#M331116</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-10-07T21:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate multiple rows of free text grouped by an ID?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-rows-of-free-text-grouped-by-an-ID/m-p/837475#M331121</link>
      <description>&lt;P&gt;I set the length to 3,500 just in case.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;length cat $3500.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I kept getting an error when I didn't specify notsorted.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a difference between&amp;nbsp;&lt;/P&gt;
&lt;P&gt;by ORDER_ID notsorted NOTE_CSN_ID notsorted LINE ;&lt;/P&gt;
&lt;P&gt;versus&lt;/P&gt;
&lt;P&gt;by ORDER_ID NOTE_CSN_ID notsorted LINE ;&lt;/P&gt;
&lt;P&gt;versus&lt;/P&gt;
&lt;P&gt;by ORDER_ID NOTE_CSN_ID LINE notsorted; ?&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2022 22:47:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-rows-of-free-text-grouped-by-an-ID/m-p/837475#M331121</guid>
      <dc:creator>PharmlyDoc</dc:creator>
      <dc:date>2022-10-07T22:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate multiple rows of free text grouped by an ID?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-rows-of-free-text-grouped-by-an-ID/m-p/837478#M331123</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/366713"&gt;@PharmlyDoc&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I set the length to 3,500 just in case.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;length cat $3500.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I kept getting an error when I didn't specify notsorted.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a difference between&amp;nbsp;&lt;/P&gt;
&lt;P&gt;by ORDER_ID notsorted NOTE_CSN_ID notsorted LINE ;&lt;/P&gt;
&lt;P&gt;versus&lt;/P&gt;
&lt;P&gt;by ORDER_ID NOTE_CSN_ID notsorted LINE ;&lt;/P&gt;
&lt;P&gt;versus&lt;/P&gt;
&lt;P&gt;by ORDER_ID NOTE_CSN_ID LINE notsorted; ?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Of course not. If you didn't sort your example data these are not in sorted order for Order_id:&lt;/P&gt;
&lt;PRE&gt;10&lt;FONT size="5" color="#800080"&gt;&lt;STRONG&gt;5&lt;/STRONG&gt;&lt;/FONT&gt;8001,44563,banana,2
10&lt;FONT size="5" color="#800080"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/FONT&gt;1569,44564,apple,1&lt;/PRE&gt;
&lt;P&gt;NOTSORTED always applies to ALL variables. You only need it once and position does not matter.&lt;/P&gt;
&lt;P&gt;From the documentation on the BY statement&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;DIV class="xis-refDictEntry"&gt;
&lt;DIV class="xis-syntax"&gt;
&lt;DIV class="xis-syntaxDescription"&gt;
&lt;DIV class="xis-otherArgGroup"&gt;
&lt;DIV id="p15nij2ef6sunen1o4m7dqh90re0" class="xis-argDescriptionPair"&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;TABLE class="xis-summary"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="xis-summaryText"&gt;statements.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD rowspan="2" class="xis-summaryTip"&gt;Tips&lt;/TD&gt;
&lt;TD class="xis-summaryText"&gt;The &lt;FONT style="background-color: #fcdec0;"&gt;NOTSORTED&lt;/FONT&gt; option can appear anywhere in the BY statement.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And my "solution"&lt;/P&gt;
&lt;PRE&gt;data want;
   set orders;
   by order_id NOTE_CSN_ID  notsorted ;
   length cat $ 2000;
   retain cat;
   if first.NOTE_CSN_ID then cat=text;
   else cat=catx(',',cat,TEXT);  
   if last.NOTE_CSN_ID then output;
run;&lt;/PRE&gt;
&lt;P&gt;If you have a large data set you might try comparing different approaches. I've always felt that the executable SET called multiple times for a single data set for this sort of problem runs slower but isn't obvious with small sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2022 23:11:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-rows-of-free-text-grouped-by-an-ID/m-p/837478#M331123</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-10-07T23:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate multiple rows of free text grouped by an ID?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-rows-of-free-text-grouped-by-an-ID/m-p/837486#M331129</link>
      <description>&lt;P&gt;I tried your solution, but just like with my solution, for some reason SAS is combining text from different ORDER_IDs in my real dataset. The TEXT column for the real data contains doctor's notes (free text) for procedure orders, which is extracted from the electronic health record, and is &lt;SPAN&gt;broken into lines of 2000 characters or less.&amp;nbsp; So a note for a procedure order could consist of multiple lines of 2000 characters each.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Each ORDER_ID has a unique NOTE_CSN_ID.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the real data, my first 3 rows, which correspond to a single ORDER_ID and NOTE_CSN_ID, but when I attempt to concatenate the 3 rows, the result pulls in free text from a different ORDER_ID/NOTE_CSN_ID.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Oct 2022 00:45:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-rows-of-free-text-grouped-by-an-ID/m-p/837486#M331129</guid>
      <dc:creator>PharmlyDoc</dc:creator>
      <dc:date>2022-10-08T00:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate multiple rows of free text grouped by an ID?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-rows-of-free-text-grouped-by-an-ID/m-p/837504#M331140</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/366713"&gt;@PharmlyDoc&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I tried your solution, but just like with my solution, for some reason SAS is combining text from different ORDER_IDs in my real dataset. The TEXT column for the real data contains doctor's notes (free text) for procedure orders, which is extracted from the electronic health record, and is &lt;SPAN&gt;broken into lines of 2000 characters or less.&amp;nbsp; So a note for a procedure order could consist of multiple lines of 2000 characters each.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Which may be very problematic to begin with. SAS variables are limited to 32K characters. So if you have more than 16 'lines' you are going to exceed the variable length.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Provide an example of the&amp;nbsp;&lt;STRONG&gt;exact&lt;/STRONG&gt; data with the problem you describe, at least the Order_id and Note_csn_id fields along with some generic text. And show the actual code that you ran. Amazingly enough, sometimes when people try to implement code on real data sets with different variables they sometimes miss one of the details that is needed to implement.&lt;/P&gt;</description>
      <pubDate>Sat, 08 Oct 2022 05:20:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-rows-of-free-text-grouped-by-an-ID/m-p/837504#M331140</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-10-08T05:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate multiple rows of free text grouped by an ID?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-rows-of-free-text-grouped-by-an-ID/m-p/837525#M331157</link>
      <description>&lt;P&gt;So it looks like your solution may be working after all.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using SAS Enterprise Guide and proc sql to query an Oracle server to produce the orders dataset. However, when I view the results in SASEG (after the query completes) row 2 (LINE 2) of the first ORDER_ID is missing a huge string of text, and is even missing when I export the orders dataset to a csv file and view it in Excel. But after concatenating and producing the "want" dataset, the missing string reappears where it's supposed to be when viewing it in Excel.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I proc print data=orders (obs=3) ; run; --the string in line 2 appears.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So now I'm trying to figure out why that string of text is missing when I export the orders dataset to a csv file.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Oct 2022 15:40:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-rows-of-free-text-grouped-by-an-ID/m-p/837525#M331157</guid>
      <dc:creator>PharmlyDoc</dc:creator>
      <dc:date>2022-10-08T15:40:41Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate multiple rows of free text grouped by an ID?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-rows-of-free-text-grouped-by-an-ID/m-p/837540#M331168</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/366713"&gt;@PharmlyDoc&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make sure that your libname statement or connect statement sets option &lt;STRONG&gt;dbmaxtext=32767&lt;/STRONG&gt;&amp;nbsp;&lt;BR /&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/n1aqglg4ftdj04n1eyvh2l3367ql.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/n1aqglg4ftdj04n1eyvh2l3367ql.htm&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1665276471797.png" style="width: 606px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76030i8E198EA0D6480D10/image-dimensions/606x47?v=v2" width="606" height="47" role="button" title="Patrick_0-1665276471797.png" alt="Patrick_0-1665276471797.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Excel does "stuff" to data. If you want to see what's really "in it" use a text editor like Notepad++&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Oct 2022 00:50:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-rows-of-free-text-grouped-by-an-ID/m-p/837540#M331168</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-10-09T00:50:03Z</dc:date>
    </item>
  </channel>
</rss>

