<?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 all fields ending with a particular word in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-all-fields-ending-with-a-particular-word/m-p/544785#M150672</link>
    <description>&lt;P&gt;Thank you ! Worked Great!&lt;/P&gt;</description>
    <pubDate>Thu, 21 Mar 2019 09:57:34 GMT</pubDate>
    <dc:creator>mohdfaisal89</dc:creator>
    <dc:date>2019-03-21T09:57:34Z</dc:date>
    <item>
      <title>Concatenate all fields ending with a particular word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-all-fields-ending-with-a-particular-word/m-p/544776#M150667</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set DMS.Dms1;
length newvar $100; /* Please adapt length as appropriate. */
newvar=catt(', ', of _A:);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Please Help !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to concatenate all the columns ending with _A in a table. I have more then 60 columns ending with _A in a table of 90 columns&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 07:59:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-all-fields-ending-with-a-particular-word/m-p/544776#M150667</guid>
      <dc:creator>mohdfaisal89</dc:creator>
      <dc:date>2019-03-21T07:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate all fields ending with a particular word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-all-fields-ending-with-a-particular-word/m-p/544778#M150669</link>
      <description>&lt;P&gt;You will need to retrieve the variable names from dictionary.columns:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input col1 $ col1_a $ col2_a $;
cards;
x y z
;
run;

proc sql noprint;
select trim(name) into :vars separated by ','
from dictionary.columns
where libname = 'WORK' and memname = 'HAVE'
  and upcase(substr(name,length(name)-1,2)) = '_A'
;
quit;

data want;
set have;
length newvar $100;
newvar = catx(',',&amp;amp;vars);
run;

proc print data=want noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;col1    col1_a    col2_a    newvar

 x        y         z        y,z  
&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Mar 2019 08:14:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-all-fields-ending-with-a-particular-word/m-p/544778#M150669</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-03-21T08:14:39Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate all fields ending with a particular word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-all-fields-ending-with-a-particular-word/m-p/544779#M150670</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data testdata;
input (ID FirstVar SecondVar ThirdVar One_A Two_A Three_A)(:$10.);
datalines;
1 1 2 3 1 2 3
2 4 5 6 4 5 6
3 7 8 9 7 8 9
4 1 2 3 1 2 3
5 4 5 6 4 5 6
;

%let suffix=A;
 
proc sql noprint;
	select name into :vars separated by ',' 
	from dictionary.columns 
	where upcase(libname)=upcase('work') 
	  and upcase(memname)=upcase('testdata')
	  and upcase(substr(name,length(name)-(length("&amp;amp;suffix")-1),length("&amp;amp;suffix")))=upcase("&amp;amp;suffix");
quit;
 
%put &amp;amp;vars;

data want;
	set testdata;
   newvar=cats(&amp;amp;vars);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Mar 2019 08:16:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-all-fields-ending-with-a-particular-word/m-p/544779#M150670</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-03-21T08:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate all fields ending with a particular word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-all-fields-ending-with-a-particular-word/m-p/544785#M150672</link>
      <description>&lt;P&gt;Thank you ! Worked Great!&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 09:57:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-all-fields-ending-with-a-particular-word/m-p/544785#M150672</guid>
      <dc:creator>mohdfaisal89</dc:creator>
      <dc:date>2019-03-21T09:57:34Z</dc:date>
    </item>
  </channel>
</rss>

