<?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: How can i merge a string and a macro variable into a new macro variable? in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/How-can-i-merge-a-string-and-a-macro-variable-into-a-new-macro/m-p/858918#M10814</link>
    <description>&lt;P&gt;This line&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let newmacro1= catx("test", &amp;amp;counter1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;will not work because CATX is a data step function, and you are not working within a data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macro variables will concatenate with other macro variables, or with plain text (such as your usage of the string 'test'), just by placing them next to one another.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let newmacro1= test&amp;amp;counter1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Feb 2023 11:55:46 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-02-15T11:55:46Z</dc:date>
    <item>
      <title>How can i merge a string and a macro variable into a new macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-can-i-merge-a-string-and-a-macro-variable-into-a-new-macro/m-p/858899#M10811</link>
      <description>&lt;P&gt;Hello guys,&lt;/P&gt;&lt;P&gt;i try to merge a string and a macro variable into a new macro variable and hope you can help me.&lt;/P&gt;&lt;P&gt;The String is e.g. test.&lt;/P&gt;&lt;P&gt;The macro variable is a counter from 1 to 3:&lt;/P&gt;&lt;P&gt;%let counter = 1;&lt;/P&gt;&lt;P&gt;And my aim is to combine them into a new macro variable that is named: test1, test2, test3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried it with "||", catx, but nothing worked :(.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope you understand what i want.&lt;/P&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 11:08:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-can-i-merge-a-string-and-a-macro-variable-into-a-new-macro/m-p/858899#M10811</guid>
      <dc:creator>Max_Meier</dc:creator>
      <dc:date>2023-02-15T11:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: How can i merge a string and a macro variable into a new macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-can-i-merge-a-string-and-a-macro-variable-into-a-new-macro/m-p/858900#M10812</link>
      <description>&lt;P&gt;Show us your code please.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 11:09:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-can-i-merge-a-string-and-a-macro-variable-into-a-new-macro/m-p/858900#M10812</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2023-02-15T11:09:45Z</dc:date>
    </item>
    <item>
      <title>Re: How can i merge a string and a macro variable into a new macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-can-i-merge-a-string-and-a-macro-variable-into-a-new-macro/m-p/858906#M10813</link>
      <description>&lt;PRE&gt;%let counter1=1;
%let counter2=2;
%let counter3=3;

%let newmacro= test || &amp;amp;counter1;
%put newmacro;

*or;

%let newmacro1= catx("test", &amp;amp;counter1);
%put newmacro1;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;That's of course just the beginning, but even there the macro "newmacro" doesn't show "test1" what i would expect.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 11:43:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-can-i-merge-a-string-and-a-macro-variable-into-a-new-macro/m-p/858906#M10813</guid>
      <dc:creator>Max_Meier</dc:creator>
      <dc:date>2023-02-15T11:43:58Z</dc:date>
    </item>
    <item>
      <title>Re: How can i merge a string and a macro variable into a new macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-can-i-merge-a-string-and-a-macro-variable-into-a-new-macro/m-p/858918#M10814</link>
      <description>&lt;P&gt;This line&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let newmacro1= catx("test", &amp;amp;counter1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;will not work because CATX is a data step function, and you are not working within a data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macro variables will concatenate with other macro variables, or with plain text (such as your usage of the string 'test'), just by placing them next to one another.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let newmacro1= test&amp;amp;counter1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 11:55:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-can-i-merge-a-string-and-a-macro-variable-into-a-new-macro/m-p/858918#M10814</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-15T11:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: How can i merge a string and a macro variable into a new macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-can-i-merge-a-string-and-a-macro-variable-into-a-new-macro/m-p/858921#M10815</link>
      <description>&lt;P&gt;Ah thanks, that helped me a lot.&lt;/P&gt;&lt;P&gt;Now i get the correct name of the Macro variable. Is there any possibility to use this string as an own macro variable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%let counter1=1;
%let test1=50000;

%let newmacro= test&amp;amp;counter1;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I mean i want to get the value 50000 from the newmacro variable?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 12:24:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-can-i-merge-a-string-and-a-macro-variable-into-a-new-macro/m-p/858921#M10815</guid>
      <dc:creator>Max_Meier</dc:creator>
      <dc:date>2023-02-15T12:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: How can i merge a string and a macro variable into a new macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-can-i-merge-a-string-and-a-macro-variable-into-a-new-macro/m-p/858925#M10816</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;First note that you're working with "macro variables" and not "macros". That's two different things.&lt;/P&gt;
&lt;P&gt;So I would use %let newmcrvar= rather than %let newmacro=.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, it is a good practice to add a dot at the end of a macro variable call. You will otherwise face some issues if you have dots in your string e.g. a dot in a filename (myfile.xlsx)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Third, when you use two ampersands one after the other, they are converted to a single ampersand.&lt;/P&gt;
&lt;P&gt;So, in your case, you currently get "test1" as output but you actually want "&amp;amp;test1." which will be automatically converted to 5000 in the second internal loop.&lt;/P&gt;
&lt;P&gt;I let you figure out the solution with this extra info.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 13:01:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-can-i-merge-a-string-and-a-macro-variable-into-a-new-macro/m-p/858925#M10816</guid>
      <dc:creator>xxformat_com</dc:creator>
      <dc:date>2023-02-15T13:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: How can i merge a string and a macro variable into a new macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-can-i-merge-a-string-and-a-macro-variable-into-a-new-macro/m-p/858928#M10817</link>
      <description>&lt;P&gt;If test&amp;amp;counter1 resolves to test1, then &amp;amp;&amp;amp;test&amp;amp;counter1 would resolve to 5000.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you already have a macro variable (test) that resolves to 5000.&amp;nbsp; Why do you need another one?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 13:34:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-can-i-merge-a-string-and-a-macro-variable-into-a-new-macro/m-p/858928#M10817</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2023-02-15T13:34:10Z</dc:date>
    </item>
  </channel>
</rss>

