<?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: Replacement for XMLAGG in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Replacement-for-XMLAGG-in-SAS/m-p/420322#M103433</link>
    <description>&lt;P&gt;You probably have to preset the necessary length. e.g.:&lt;/P&gt;
&lt;PRE&gt;data want (drop=product);
  set have;
  length NewColumn $350;
  by id;
  retain NewColumn;
  if first.id then NewColumn=product;
  else NewColumn=catx(',',NewColumn,product);
  if last.id then output;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
    <pubDate>Tue, 12 Dec 2017 00:14:38 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2017-12-12T00:14:38Z</dc:date>
    <item>
      <title>Replacement for XMLAGG in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacement-for-XMLAGG-in-SAS/m-p/420304#M103425</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was using the XMLAGG function in Oracle and it throws me an error. Would like to try the same in SAS. Need a new column with all the values separated by comma.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please&amp;nbsp; note: The product data is huge and hence I got the error in Oracle like&lt;/P&gt;&lt;P&gt;ERROR: ORACLE execute error: ORA-19011: Character string buffer too small.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; Product&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; s&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; j&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; k&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Id&amp;nbsp; &amp;nbsp;NewColumn&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;x,y&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp;s,j,k&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for looking!&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2017 22:51:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacement-for-XMLAGG-in-SAS/m-p/420304#M103425</guid>
      <dc:creator>Kalai2008</dc:creator>
      <dc:date>2017-12-11T22:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: Replacement for XMLAGG in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacement-for-XMLAGG-in-SAS/m-p/420306#M103426</link>
      <description>&lt;P&gt;If you can use the AGG function via SQL pass through that's your best option.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you can't, another option is to transpose the data and then use CATX or you can use a data step and loop through it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This question was asked recently regarding the AGG type functionality and unfortunately SAS doesn't have it implemented at the moment. There is a ballot ware item to have it added.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2017 22:57:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacement-for-XMLAGG-in-SAS/m-p/420306#M103426</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-11T22:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: Replacement for XMLAGG in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacement-for-XMLAGG-in-SAS/m-p/420307#M103427</link>
      <description>&lt;P&gt;While SAS doesn't have the function, you can easily do it using SAS. e.g.:&lt;/P&gt;
&lt;PRE&gt;data want (drop=product);
  set have;
  by id;
  retain NewColumn;
  if first.id then NewColumn=product;
  else NewColumn=catx(',',NewColumn,product);
  if last.id then output;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2017 23:07:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacement-for-XMLAGG-in-SAS/m-p/420307#M103427</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-12-11T23:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: Replacement for XMLAGG in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacement-for-XMLAGG-in-SAS/m-p/420310#M103428</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;&amp;nbsp;solution assumes the data is pre-sorted. In a big data set I suspect that assumption is invalid. If it is, then it's relatively easy to aggregate what you need.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2017 23:19:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacement-for-XMLAGG-in-SAS/m-p/420310#M103428</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-11T23:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: Replacement for XMLAGG in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacement-for-XMLAGG-in-SAS/m-p/420320#M103431</link>
      <description>Its not concatenating all the products. Each product size is 23 character. So there are 14 products and concatenated only 6 products. Do you know the reason?</description>
      <pubDate>Mon, 11 Dec 2017 23:59:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacement-for-XMLAGG-in-SAS/m-p/420320#M103431</guid>
      <dc:creator>Kalai2008</dc:creator>
      <dc:date>2017-12-11T23:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: Replacement for XMLAGG in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacement-for-XMLAGG-in-SAS/m-p/420322#M103433</link>
      <description>&lt;P&gt;You probably have to preset the necessary length. e.g.:&lt;/P&gt;
&lt;PRE&gt;data want (drop=product);
  set have;
  length NewColumn $350;
  by id;
  retain NewColumn;
  if first.id then NewColumn=product;
  else NewColumn=catx(',',NewColumn,product);
  if last.id then output;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 00:14:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacement-for-XMLAGG-in-SAS/m-p/420322#M103433</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-12-12T00:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: Replacement for XMLAGG in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacement-for-XMLAGG-in-SAS/m-p/420323#M103434</link>
      <description>&lt;P&gt;How long did you make the LENGTH of the target variable? If a variable is to hold a comma delimited list it would need 26*14 characters for the product and an additional 13 for commas between 14 of them. Total 335. Less than that is likely not to hold any group requiring all 14 variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Likely the length of your resulting variable is around 160 OR you getting lots of blanks carried around for some reason.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It never hurts to show the actual code you ran as we can't see anything you don't share and have to ask questions that would be answered by the code.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 00:17:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacement-for-XMLAGG-in-SAS/m-p/420323#M103434</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-12-12T00:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: Replacement for XMLAGG in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacement-for-XMLAGG-in-SAS/m-p/420328#M103438</link>
      <description>&lt;P&gt;Yes, I already added a length statement to 500. Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 00:37:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacement-for-XMLAGG-in-SAS/m-p/420328#M103438</guid>
      <dc:creator>Kalai2008</dc:creator>
      <dc:date>2017-12-12T00:37:49Z</dc:date>
    </item>
    <item>
      <title>Re: Replacement for XMLAGG in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacement-for-XMLAGG-in-SAS/m-p/420329#M103439</link>
      <description>&lt;P&gt;And did that correct the problem? If not, post your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 00:44:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacement-for-XMLAGG-in-SAS/m-p/420329#M103439</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-12-12T00:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: Replacement for XMLAGG in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacement-for-XMLAGG-in-SAS/m-p/420353#M103447</link>
      <description>The product Number looks like this 'ABCD0000000345789479607'. Each customer (ID) have several Product Numbers. One customer can have 1 to 5000 product numbers. I used the same query and increased the length to 32767 (max). 23*5000=115,000. I don't think we can increase the length. The same reason oracle throwed me error in XMLAGG function.&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Dec 2017 03:48:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacement-for-XMLAGG-in-SAS/m-p/420353#M103447</guid>
      <dc:creator>Kalai2008</dc:creator>
      <dc:date>2017-12-12T03:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: Replacement for XMLAGG in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacement-for-XMLAGG-in-SAS/m-p/420358#M103450</link>
      <description>&lt;P&gt;Do you need to end up with the non-attainable extra long string or would something like the following suffice:&lt;/P&gt;
&lt;PRE&gt;data want (drop=product);
  set have;
  array NewColumn(5000) $14.;
  by id;
  retain i NewColumn:;
  if first.id then do;
    call missing(of NewColumn(*));
    i=1;
  end;
  else i+1;
  NewColumn(i)=product;
  if last.id then output;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 04:17:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacement-for-XMLAGG-in-SAS/m-p/420358#M103450</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-12-12T04:17:08Z</dc:date>
    </item>
  </channel>
</rss>

