<?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 How to concat multiple variable with different name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-concat-multiple-variable-with-different-name/m-p/945209#M370326</link>
    <description>&lt;P&gt;So I have code where I want concat&amp;nbsp;multiple(almost 30)&amp;nbsp; variable with different variable name&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For now am using ;&lt;/P&gt;
&lt;P&gt;New = name||age||gender||sex||dob||addrees&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Like this I have 30 var to concat&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;is there are any efficent way to do this&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Sep 2024 15:01:41 GMT</pubDate>
    <dc:creator>animesh123</dc:creator>
    <dc:date>2024-09-25T15:01:41Z</dc:date>
    <item>
      <title>How to concat multiple variable with different name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-concat-multiple-variable-with-different-name/m-p/945209#M370326</link>
      <description>&lt;P&gt;So I have code where I want concat&amp;nbsp;multiple(almost 30)&amp;nbsp; variable with different variable name&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For now am using ;&lt;/P&gt;
&lt;P&gt;New = name||age||gender||sex||dob||addrees&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Like this I have 30 var to concat&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;is there are any efficent way to do this&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2024 15:01:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-concat-multiple-variable-with-different-name/m-p/945209#M370326</guid>
      <dc:creator>animesh123</dc:creator>
      <dc:date>2024-09-25T15:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to concat multiple variable with different name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-concat-multiple-variable-with-different-name/m-p/945210#M370327</link>
      <description>&lt;P&gt;If the variables are consecutive in the data set, so you want to concatenate all variables from firstvariablename to lastvariablename, use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;newvariable=cat(of firstvariablename -- lastvariablename);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other possibilities exist, depending on the location in the data set and whether variables are all numeric or all character. Do tell us more about this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, I question how having all this information in a a very long text variable is a superior way to arrange your data compared to leaving them as individual variables. Why do you need this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2024 15:27:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-concat-multiple-variable-with-different-name/m-p/945210#M370327</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-09-25T15:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to concat multiple variable with different name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-concat-multiple-variable-with-different-name/m-p/945216#M370328</link>
      <description>&lt;P&gt;First is use one of the newer concatenation functions instead of the || operator.&lt;/P&gt;
&lt;P&gt;Check out CATS() or CATX() as the most useful.&amp;nbsp; But there are others.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once you are doing that you can then use variable lists in the function call.&amp;nbsp; That requires you to use the OF keyword.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;string=catx('|',of name -- address);
string=catx('|',of _character_);
string=catx('|',of _all_);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Depending on the list and the dataset it might even be easier to use the DROP= dataset option to so that you only have to list the variables you don't want to include instead of the ones you do want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have(drop=ignore_me);
  length string $200;
  string = catx('|',of _all_);
  set have;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Sep 2024 15:39:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-concat-multiple-variable-with-different-name/m-p/945216#M370328</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-09-25T15:39:03Z</dc:date>
    </item>
  </channel>
</rss>

