<?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 macro variables into macro variable called vector in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-macro-variables-into-macro-variable-called-vector/m-p/666571#M199461</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;you could use optinos:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let YYMM1=2005;
%let YYMM2=.;
%let YYMM3=1912;

options missing=" ";
%let vector3=%sysfunc(catx(+,&amp;amp;YYMM1.,&amp;amp;YYMM2.,&amp;amp;YYMM3.));
%put &amp;amp;vector3.;/*2005+1912*/

options missing=.;
%let vector4=%sysfunc(catx(+,&amp;amp;YYMM1.,&amp;amp;YYMM2.,&amp;amp;YYMM3.));
%put &amp;amp;vector4.;/*2005+.+1912*/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;All the best&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
    <pubDate>Thu, 02 Jul 2020 09:56:22 GMT</pubDate>
    <dc:creator>yabwon</dc:creator>
    <dc:date>2020-07-02T09:56:22Z</dc:date>
    <item>
      <title>Concatenate macro variables into macro variable called vector</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-macro-variables-into-macro-variable-called-vector/m-p/666544#M199450</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to concatenate macro varaibles into a new macro varaible with plus sign between values.&lt;/P&gt;
&lt;P&gt;Please note that there is no calculation here and just concatenate of values with + sign.&lt;/P&gt;
&lt;P&gt;My question is how to tell SAS that If values contain null (dot) then no need to include it in the new macro variable.&lt;/P&gt;
&lt;P&gt;Instead of getting&amp;nbsp;&amp;nbsp;&lt;CODE class=" language-sas"&gt;2005+.+1912 &amp;nbsp;I&amp;nbsp;nant&amp;nbsp;to&amp;nbsp;get&amp;nbsp;&amp;nbsp;2005+1912&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let YYMM1=2005;
%let YYMM2=.;
%let YYMM3=1912;
%let vector=%sysfunc(catx(+,&amp;amp;YYMM1,&amp;amp;YYMM2.,&amp;amp;YYMM3.));
%put &amp;amp;vector3.;/*2005+.+1912*/
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Jul 2020 05:31:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-macro-variables-into-macro-variable-called-vector/m-p/666544#M199450</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-07-02T05:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate macro variables into macro variable called vector</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-macro-variables-into-macro-variable-called-vector/m-p/666545#M199451</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to concatenate macro varaibles into a new macro varaible with plus sign between values.&lt;/P&gt;
&lt;P&gt;Please note that there is no calculation here and just concatenate of values with + sign.&lt;/P&gt;
&lt;P&gt;My question is how to tell SAS that If values contain null (dot) then no need to include it in the new macro variable.&lt;/P&gt;
&lt;P&gt;Instead of getting&amp;nbsp;&amp;nbsp;&lt;CODE class=" language-sas"&gt;2005+.+1912 &amp;nbsp;I&amp;nbsp;nant&amp;nbsp;to&amp;nbsp;get&amp;nbsp;&amp;nbsp;2005+1912&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let YYMM1=2005;
%let YYMM2=.;
%let YYMM3=1912;
%let vector=%sysfunc(catx(+,&amp;amp;YYMM1,&amp;amp;YYMM2.,&amp;amp;YYMM3.));
%put &amp;amp;vector3.;/*2005+.+1912*/
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Use a data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let YYMM1=2005;
%let YYMM2=.;
%let YYMM3=1912;

data _null_;
length vector $32767;
do i = 1 to 3;
  vec = symget(cats('yymm',i));
  if vec ne '.' then vector = catx('+',vector,vec);
end;
call symputx('vector',vector);
run;

%put &amp;amp;=vector.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log excerpt:&lt;/P&gt;
&lt;PRE&gt; 85         
 86         %put &amp;amp;=vector.;
 VECTOR=2005+1912
 &lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Jul 2020 05:39:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-macro-variables-into-macro-variable-called-vector/m-p/666545#M199451</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-02T05:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate macro variables into macro variable called vector</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-macro-variables-into-macro-variable-called-vector/m-p/666546#M199452</link>
      <description>&lt;P&gt;Macro variables are strings. The string . is a valid string. You are better off removing the dot when the macro variable is populated.&lt;/P&gt;
&lt;P&gt;Otherwise you need to process the string. Something like&amp;nbsp;:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;%let vector=%sysfunc(catx(+
                         ,%sysfunc(ifc(&amp;amp;yymm1=.,,&amp;amp;yymm1))
                         ,%sysfunc(ifc(&amp;amp;yymm1=.,,&amp;amp;yymm1))
                         ,%sysfunc(ifc(&amp;amp;yymm1=.,,&amp;amp;yymm1))
                   ));&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jul 2020 05:50:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-macro-variables-into-macro-variable-called-vector/m-p/666546#M199452</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-07-02T05:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate macro variables into macro variable called vector</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-macro-variables-into-macro-variable-called-vector/m-p/666562#M199458</link>
      <description>&lt;P&gt;It can be done with PRXCHANGE, e.g.:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let vector=%sysfunc(prxchange(s/(\+\.|\.\+)//,-1,%sysfunc(catx(+,&amp;amp;YYMM1,&amp;amp;YYMM2.,&amp;amp;YYMM3.))));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The string deletes ".+" or "+." - the backslashes are there to escape the special characters "+" and ".".&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jul 2020 08:32:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-macro-variables-into-macro-variable-called-vector/m-p/666562#M199458</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2020-07-02T08:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate macro variables into macro variable called vector</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-macro-variables-into-macro-variable-called-vector/m-p/666563#M199459</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A slightly different version using an array and the $charw informat to read missing numeric values as spaces.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let YYMM1=2005;
%let YYMM2=.;
%let YYMM3=1912;


data _NULL_;
informat YYMM: $char4.;
array vector YYMM1-YYMM3;

do over vector;
    vector=symget(vname(vector));
end;

call symputx("vector", catx('+', of vector(*)));
run;

%put &amp;amp;vector;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Jul 2020 08:35:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-macro-variables-into-macro-variable-called-vector/m-p/666563#M199459</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2020-07-02T08:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate macro variables into macro variable called vector</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-macro-variables-into-macro-variable-called-vector/m-p/666571#M199461</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;you could use optinos:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let YYMM1=2005;
%let YYMM2=.;
%let YYMM3=1912;

options missing=" ";
%let vector3=%sysfunc(catx(+,&amp;amp;YYMM1.,&amp;amp;YYMM2.,&amp;amp;YYMM3.));
%put &amp;amp;vector3.;/*2005+1912*/

options missing=.;
%let vector4=%sysfunc(catx(+,&amp;amp;YYMM1.,&amp;amp;YYMM2.,&amp;amp;YYMM3.));
%put &amp;amp;vector4.;/*2005+.+1912*/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;All the best&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jul 2020 09:56:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-macro-variables-into-macro-variable-called-vector/m-p/666571#M199461</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-07-02T09:56:22Z</dc:date>
    </item>
  </channel>
</rss>

