<?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: concatenate columns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/concatenate-columns/m-p/669827#M200990</link>
    <description>&lt;P&gt;ok then try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data t2204_new;
length Revenue_new $200.;
set t2004;
Revenue_new=CATX(',',of Revenue:);

Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 16 Jul 2020 08:02:47 GMT</pubDate>
    <dc:creator>Jagadishkatam</dc:creator>
    <dc:date>2020-07-16T08:02:47Z</dc:date>
    <item>
      <title>concatenate columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenate-columns/m-p/669819#M200985</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I have the following question.&lt;/P&gt;
&lt;P&gt;In each month I get a data set that is sent to me (I don't create it).&lt;/P&gt;
&lt;P&gt;The structure of the table is not fixed and there are different columns every month.&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;In month June 2020 there are 3 columns of revenue called: Revenue1,Revenue2,Revenue3&lt;/P&gt;
&lt;P&gt;In month May 2020 there are 2 columns of revenue called: Revenue1,Revenue2&lt;/P&gt;
&lt;P&gt;In month April 2020 there are 2 columns of revenue called: Revenue1,Revenue2,Revenue3,Revenue4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In every month after getting the data set I need to perform manipulation on the data set.&lt;/P&gt;
&lt;P&gt;Let's say that I want to concatenate all variables that have following name "Revenue"(with comma between values)&lt;/P&gt;
&lt;P&gt;What is the way to concatenate the columns with name&amp;nbsp;Revenue when I don't know in advance how many columns with these name&amp;nbsp; have.&lt;/P&gt;
&lt;P&gt;I am looking for a dynamic code that concatenate fields when number of fields is not fixed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data t2004;
input Id Revenue1 Revenue2 Revenue3 Revenue4;
cards;
1 10 20 30 40
2 15 30 45 60
3 5 10 15 20
;
Run;

Data t2204_new;
set t2004;
Revenue_new=CATX(',',Revenue1,Revenue2,Revenue3,Revenue4);
/*need to find way to do it without knowing number of columns before*/
Run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 07:30:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenate-columns/m-p/669819#M200985</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-07-16T07:30:10Z</dc:date>
    </item>
    <item>
      <title>Re: concatenate columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenate-columns/m-p/669823#M200986</link>
      <description>&lt;P&gt;you may try &lt;BR /&gt;&lt;BR /&gt;Revenue_new=CATX(',', of Revenue1--Revenue4);&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 07:53:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenate-columns/m-p/669823#M200986</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-07-16T07:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: concatenate columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenate-columns/m-p/669824#M200987</link>
      <description>&lt;P&gt;Use a wildcard and the OF keyword:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set t2004;
length revenue_new $20;
revenue_new = catx(',',of revenue:);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Jul 2020 07:53:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenate-columns/m-p/669824#M200987</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-16T07:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: concatenate columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenate-columns/m-p/669825#M200988</link>
      <description>&lt;P&gt;It is not good because you don't know in advance that there are 4 Revenue columns.&lt;/P&gt;
&lt;P&gt;This is exactly the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 07:59:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenate-columns/m-p/669825#M200988</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-07-16T07:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: concatenate columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenate-columns/m-p/669827#M200990</link>
      <description>&lt;P&gt;ok then try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data t2204_new;
length Revenue_new $200.;
set t2004;
Revenue_new=CATX(',',of Revenue:);

Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Jul 2020 08:02:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenate-columns/m-p/669827#M200990</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-07-16T08:02:47Z</dc:date>
    </item>
  </channel>
</rss>

