<?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: concat multiple num var into 1 char in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/concat-multiple-num-var-into-1-char/m-p/456997#M284390</link>
    <description>&lt;P&gt;If you use the CATX function, your numeric variables will automatically be converted into character, with leading and trailing spaces removed. However, make sure you mention your variables as individual arguments for the function, not as one long concatenated string. I've included a space delimiter, the first argument to the CATX function, but you could change this to "|" if you need to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And of course, you can use this in PROC SQL as well.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   select catx(' ',id,rank,count,date) as fin
   from have;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 24 Apr 2018 18:07:33 GMT</pubDate>
    <dc:creator>antonbcristina</dc:creator>
    <dc:date>2018-04-24T18:07:33Z</dc:date>
    <item>
      <title>concat multiple num var into 1 char</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concat-multiple-num-var-into-1-char/m-p/456990#M284388</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have multiple numeric variables that I want to copy all into 1 new variable.&amp;nbsp; I can do it&amp;nbsp;using PUT.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a another way of doing it (preferably that would also work in SQL)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advance,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input Id  Rank Count Date;
datalines;
001  01    01     2017
001  02    01     9999
002  01    03     9999
003  01    02     2018
003  02    02     9999
004  01    02     9999
run;

data want;
/*format a $3. b $2. c $2. d $4.; */

set have;
a=PUT(id,best.);
b=PUT(rank,best.);
c=PUT(count,best.);
d=PUT(date,best.);
fin=catx('|',a||b||c||d);

keep fin;


run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Apr 2018 17:52:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concat-multiple-num-var-into-1-char/m-p/456990#M284388</guid>
      <dc:creator>brulard</dc:creator>
      <dc:date>2018-04-24T17:52:39Z</dc:date>
    </item>
    <item>
      <title>Re: concat multiple num var into 1 char</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concat-multiple-num-var-into-1-char/m-p/456995#M284389</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/64767"&gt;@brulard&lt;/a&gt;wrote:&lt;BR /&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have multiple numeric variables that I want to copy all into 1 new variable.&amp;nbsp; I can do it&amp;nbsp;using PUT.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a another way of doing it (preferably that would also work in SQL)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advance,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input Id  Rank Count Date;
datalines;
001  01    01     2017
001  02    01     9999
002  01    03     9999
003  01    02     2018
003  02    02     9999
004  01    02     9999
run;

data want;
/*format a $3. b $2. c $2. d $4.; */

set have;
a=PUT(id,best.);
b=PUT(rank,best.);
c=PUT(count,best.);
d=PUT(date,best.);
fin=catx('|',a||b||c||d);

keep fin;


run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;How come there is no delimiter in '|' in your output fin?&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 18:03:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concat-multiple-num-var-into-1-char/m-p/456995#M284389</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-04-24T18:03:46Z</dc:date>
    </item>
    <item>
      <title>Re: concat multiple num var into 1 char</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concat-multiple-num-var-into-1-char/m-p/456997#M284390</link>
      <description>&lt;P&gt;If you use the CATX function, your numeric variables will automatically be converted into character, with leading and trailing spaces removed. However, make sure you mention your variables as individual arguments for the function, not as one long concatenated string. I've included a space delimiter, the first argument to the CATX function, but you could change this to "|" if you need to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And of course, you can use this in PROC SQL as well.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   select catx(' ',id,rank,count,date) as fin
   from have;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 18:07:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concat-multiple-num-var-into-1-char/m-p/456997#M284390</guid>
      <dc:creator>antonbcristina</dc:creator>
      <dc:date>2018-04-24T18:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: concat multiple num var into 1 char</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concat-multiple-num-var-into-1-char/m-p/457000#M284391</link>
      <description>&lt;P&gt;Appreciate the explanation, thank you&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 18:12:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concat-multiple-num-var-into-1-char/m-p/457000#M284391</guid>
      <dc:creator>brulard</dc:creator>
      <dc:date>2018-04-24T18:12:14Z</dc:date>
    </item>
  </channel>
</rss>

