<?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 Passing concatenated string to macro in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Passing-concatenated-string-to-macro/m-p/507903#M1539</link>
    <description>&lt;P&gt;I am attempting to concatenate various values to a string: macro variables, number variables, _N_, plain text, even an&amp;nbsp;observation from a dataset. Then pass the sting to a macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro err_msg(param_msg);
	%put &amp;amp;=param_msg;
%mend err_msg;
data _null_;
	%let TargetYear="2018";
	number = 27;
	msg = cat('Note: The year is ', &amp;amp;TargetYear, ', number is ', number);
	put msg $char.;
	%err_msg(msg);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But this is what I get in the log&lt;/P&gt;&lt;PRE&gt;24 %let err_msg_init = 1;&lt;BR /&gt;25 %let RedTitle= font='Consolas' color=red height=14pt;&lt;BR /&gt;26 &lt;BR /&gt;27 %macro err_msg(param_msg);&lt;BR /&gt;28 %put &amp;amp;=param_msg;&lt;BR /&gt;29 %mend err_msg;&lt;BR /&gt;30 data _null_;&lt;BR /&gt;31 %let TargetYear="2018";&lt;BR /&gt;32 number = 27;&lt;BR /&gt;33 msg = cat('Note: The year is ', &amp;amp;TargetYear, ', number is ', number);&lt;BR /&gt;34 put msg $char.;&lt;BR /&gt;35 %err_msg(msg);&lt;BR /&gt;&lt;FONT size="4" color="#FF0000"&gt;PARAM_MSG=msg&lt;/FONT&gt;&lt;BR /&gt;36 run;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="4" color="#3366FF"&gt;Note: The year is 2018, number is 27 &lt;/FONT&gt;&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt; real time 0.00 seconds&lt;BR /&gt; cpu time 0.01 seconds&lt;/PRE&gt;&lt;P&gt;String in blue seems to concat OK, but shown in red, the macro sees "msg"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Thanks in advance.&lt;/P&gt;</description>
    <pubDate>Fri, 26 Oct 2018 21:40:19 GMT</pubDate>
    <dc:creator>Espresso</dc:creator>
    <dc:date>2018-10-26T21:40:19Z</dc:date>
    <item>
      <title>Passing concatenated string to macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Passing-concatenated-string-to-macro/m-p/507903#M1539</link>
      <description>&lt;P&gt;I am attempting to concatenate various values to a string: macro variables, number variables, _N_, plain text, even an&amp;nbsp;observation from a dataset. Then pass the sting to a macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro err_msg(param_msg);
	%put &amp;amp;=param_msg;
%mend err_msg;
data _null_;
	%let TargetYear="2018";
	number = 27;
	msg = cat('Note: The year is ', &amp;amp;TargetYear, ', number is ', number);
	put msg $char.;
	%err_msg(msg);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But this is what I get in the log&lt;/P&gt;&lt;PRE&gt;24 %let err_msg_init = 1;&lt;BR /&gt;25 %let RedTitle= font='Consolas' color=red height=14pt;&lt;BR /&gt;26 &lt;BR /&gt;27 %macro err_msg(param_msg);&lt;BR /&gt;28 %put &amp;amp;=param_msg;&lt;BR /&gt;29 %mend err_msg;&lt;BR /&gt;30 data _null_;&lt;BR /&gt;31 %let TargetYear="2018";&lt;BR /&gt;32 number = 27;&lt;BR /&gt;33 msg = cat('Note: The year is ', &amp;amp;TargetYear, ', number is ', number);&lt;BR /&gt;34 put msg $char.;&lt;BR /&gt;35 %err_msg(msg);&lt;BR /&gt;&lt;FONT size="4" color="#FF0000"&gt;PARAM_MSG=msg&lt;/FONT&gt;&lt;BR /&gt;36 run;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="4" color="#3366FF"&gt;Note: The year is 2018, number is 27 &lt;/FONT&gt;&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt; real time 0.00 seconds&lt;BR /&gt; cpu time 0.01 seconds&lt;/PRE&gt;&lt;P&gt;String in blue seems to concat OK, but shown in red, the macro sees "msg"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Oct 2018 21:40:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Passing-concatenated-string-to-macro/m-p/507903#M1539</guid>
      <dc:creator>Espresso</dc:creator>
      <dc:date>2018-10-26T21:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: Passing concatenated string to macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Passing-concatenated-string-to-macro/m-p/507904#M1540</link>
      <description>&lt;P&gt;You are missing semi colon here&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;number &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;27&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;should be&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;number &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;27;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Oct 2018 21:35:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Passing-concatenated-string-to-macro/m-p/507904#M1540</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-26T21:35:41Z</dc:date>
    </item>
    <item>
      <title>Re: Passing concatenated string to macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Passing-concatenated-string-to-macro/m-p/507905#M1541</link>
      <description>&lt;P&gt;I saw that, thanks a lot fixed, still have the macro not seeing the string.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Oct 2018 21:37:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Passing-concatenated-string-to-macro/m-p/507905#M1541</guid>
      <dc:creator>Espresso</dc:creator>
      <dc:date>2018-10-26T21:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: Passing concatenated string to macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Passing-concatenated-string-to-macro/m-p/507906#M1542</link>
      <description>&lt;P&gt;missing ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;30         data _null_;
31         	%let TargetYear="2018";
32         	number = 27         &lt;STRONG&gt;&lt;FONT color="#993366"&gt;&amp;lt;= should have ;
&lt;/FONT&gt;&lt;/STRONG&gt;33         	msg = cat('Note: The year is ', &amp;amp;TargetYear, ', number is ', number);
&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Oct 2018 21:37:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Passing-concatenated-string-to-macro/m-p/507906#M1542</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-26T21:37:32Z</dc:date>
    </item>
    <item>
      <title>Re: Passing concatenated string to macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Passing-concatenated-string-to-macro/m-p/507907#M1543</link>
      <description>&lt;P&gt;Thanks, fixed and I only have the macro not seeing the string, only the word "msg", shown in red.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Oct 2018 21:42:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Passing-concatenated-string-to-macro/m-p/507907#M1543</guid>
      <dc:creator>Espresso</dc:creator>
      <dc:date>2018-10-26T21:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: Passing concatenated string to macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Passing-concatenated-string-to-macro/m-p/507908#M1544</link>
      <description>&lt;P&gt;Seems to be taking msg as just a string instead of passing the actual variable in&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token macroname"&gt;%err_msg&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;msg&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Oct 2018 21:45:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Passing-concatenated-string-to-macro/m-p/507908#M1544</guid>
      <dc:creator>Espresso</dc:creator>
      <dc:date>2018-10-26T21:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: Passing concatenated string to macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Passing-concatenated-string-to-macro/m-p/507909#M1545</link>
      <description>&lt;P&gt;You need &lt;STRONG&gt;call execute&lt;/STRONG&gt; or &lt;STRONG&gt;resolve&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lots of examples available online but pretty boring syntax though dealing with concatenation of literals lol&lt;/P&gt;</description>
      <pubDate>Fri, 26 Oct 2018 21:47:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Passing-concatenated-string-to-macro/m-p/507909#M1545</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-26T21:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: Passing concatenated string to macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Passing-concatenated-string-to-macro/m-p/507912#M1546</link>
      <description>&lt;P&gt;I like resolve &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%macro err_msg(param_msg);
	param_msg is  &amp;amp;param_msg;
%mend err_msg;
data _null;
	%let TargetYear="2018";
	number = 27;
	msg = cat('Note: The year is ', &amp;amp;TargetYear, ' number is ', number);
	   	   x=resolve('%err_msg'||'('||msg||')');
put +5 x=;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Oct 2018 22:33:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Passing-concatenated-string-to-macro/m-p/507912#M1546</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-26T22:33:36Z</dc:date>
    </item>
    <item>
      <title>Re: Passing concatenated string to macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Passing-concatenated-string-to-macro/m-p/507913#M1547</link>
      <description>&lt;P&gt;Thanks a lot will chew on this, a little slow as newbie.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Oct 2018 21:55:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Passing-concatenated-string-to-macro/m-p/507913#M1547</guid>
      <dc:creator>Espresso</dc:creator>
      <dc:date>2018-10-26T21:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: Passing concatenated string to macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Passing-concatenated-string-to-macro/m-p/507915#M1548</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/239870"&gt;@Espresso&lt;/a&gt;&amp;nbsp;My apologies for the laziness on my part. Here you go:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%macro err_msg(param_msg);
	%put &amp;amp;=param_msg;
%mend err_msg;
data _null_;
	%let TargetYear="2018";
	number = 27;
	msg = cat('Note: The year is ', &amp;amp;TargetYear, ' number is ', number);
	   call execute('%err_msg'||'('||left(msg)||')');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Oct 2018 22:23:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Passing-concatenated-string-to-macro/m-p/507915#M1548</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-26T22:23:05Z</dc:date>
    </item>
    <item>
      <title>Re: Passing concatenated string to macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Passing-concatenated-string-to-macro/m-p/507933#M1555</link>
      <description>&lt;P&gt;Given what you have gone through so far, here are more important lessons that are more appropriate for a relative newcomer to SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, macro language statements are not part of a DATA step.&amp;nbsp; Macro language does not recognize DATA step variables.&amp;nbsp; Thus your observation is correct:&amp;nbsp; %err_msg(msg) is treating "msg" as three letters, not as a reference to a variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, the DATA step is able to transfer a DATA step value to a macro variable.&amp;nbsp; It contains special tools for this purpose, such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;call symputx('message', msg);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This transfers the value of the DATA step variable MSG to a macro variable named MESSAGE.&amp;nbsp; If you were to include that line in your DATA step, you could add:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;=message;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You would have to add this AFTER the DATA step completes running, meaning after the RUN statement that ends the DATA step.&lt;/P&gt;</description>
      <pubDate>Sat, 27 Oct 2018 02:33:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Passing-concatenated-string-to-macro/m-p/507933#M1555</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-10-27T02:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: Passing concatenated string to macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Passing-concatenated-string-to-macro/m-p/510208#M1898</link>
      <description>&lt;P&gt;Perhaps macro is not the way to go then.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OK, this question is a subset of the bigger purpose I need to accomplish, so I will start a new thread, than you all.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Nov 2018 21:37:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Passing-concatenated-string-to-macro/m-p/510208#M1898</guid>
      <dc:creator>Espresso</dc:creator>
      <dc:date>2018-11-03T21:37:36Z</dc:date>
    </item>
  </channel>
</rss>

