<?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: Macro variable not resolving in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-not-resolving/m-p/877233#M346551</link>
    <description>&lt;P&gt;Put double quotes around the macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let parameter_2 = Data Management;

data _null_;
test = '/'||"&amp;amp;parameter_2"||'/';
put test=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 24 May 2023 09:42:19 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2023-05-24T09:42:19Z</dc:date>
    <item>
      <title>Macro variable not resolving</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-not-resolving/m-p/877231#M346549</link>
      <description>&lt;P&gt;If the value of the macro variable have spaces then the following code is throwing the syntax error. Code and log is shown below. Any help to resolve the issue?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Value of macro variable 'parameter_2' resolves to 'Data Management'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Program:&lt;/P&gt;
&lt;PRE&gt;proc print data=sorted_nodup noobs;
where &amp;amp;parameter_1 IN("&amp;amp;parameter_2");
var &amp;amp;_field;
run;

data _null_;
test = '/'||&amp;amp;parameter_2||'/';
put test=;
run;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt;12   proc print data=sorted_nodup noobs;
13   where &amp;amp;parameter_1 IN("&amp;amp;parameter_2");
14   var &amp;amp;_field;
15   run;

NOTE: There were 194 observations read from the data set WORK.SORTED_NODUP.
      WHERE DIVISION='Data Management';
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      

16   
17   data _null_;
18   test = '/'||&amp;amp;parameter_2||'/';
NOTE: Line generated by the macro variable "PARAMETER_2".
18   Data Management
            ----------
            22
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, (, *, **, +, -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT, 
              LE, LT, MAX, MIN, NE, NG, NL, OR, [, ^=, {, |, ||, ~=.  

19   put test=;
20   run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 09:37:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-not-resolving/m-p/877231#M346549</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2023-05-24T09:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable not resolving</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-not-resolving/m-p/877233#M346551</link>
      <description>&lt;P&gt;Put double quotes around the macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let parameter_2 = Data Management;

data _null_;
test = '/'||"&amp;amp;parameter_2"||'/';
put test=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 May 2023 09:42:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-not-resolving/m-p/877233#M346551</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2023-05-24T09:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable not resolving</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-not-resolving/m-p/877234#M346552</link>
      <description>&lt;P&gt;The log shows clearly that the macro variable is indeed resolving properly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;17   data _null_;
18   test = '/'||&amp;amp;parameter_2||'/';
NOTE: Line generated by the macro variable "PARAMETER_2".
18   Data Management
            ----------
            22
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, (, *, **, +, -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT, 
              LE, LT, MAX, MIN, NE, NG, NL, OR, [, ^=, {, |, ||, ~=.  

19   put test=;
20   run;&lt;/PRE&gt;
&lt;P&gt;It is using the proper value of the macro variable, specifically Data Management, when it creates the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem is that the macro is not creating valid legal working code in SAS, that's why you see the ERROR. The code your usage of this macro is creating is this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
test = '/'||Data Management||'/';
put test=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you see where the error is? Can you see why this code does not work? Please fix it, first without macros, just get those four lines directly above to work.&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 12:02:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-not-resolving/m-p/877234#M346552</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-24T12:02:54Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable not resolving</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-not-resolving/m-p/877235#M346553</link>
      <description>How to handle this macro variable when it is separated by commas. E.g. Data&lt;BR /&gt;Management, Data Analytics.&lt;BR /&gt;&lt;BR /&gt;Sometimes it will resolve with Data Management and sometimes with Data&lt;BR /&gt;Management, Data Analytics&lt;BR /&gt;</description>
      <pubDate>Wed, 24 May 2023 09:54:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-not-resolving/m-p/877235#M346553</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2023-05-24T09:54:34Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable not resolving</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-not-resolving/m-p/877238#M346554</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;How to handle this macro variable when it is separated by commas. E.g. Data&lt;BR /&gt;Management, Data Analytics.&lt;BR /&gt;&lt;BR /&gt;Sometimes it will resolve with Data Management and sometimes with Data&lt;BR /&gt;Management, Data Analytics&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't see why this creates a problem, unless you are doing something different than what you showed above. The following code works fine:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let parameter2=Data Management, Data Analytics;
%put &amp;amp;=parameter2;

data _null_;
test = '/'||"&amp;amp;parameter2"||'/';
put test=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show us how you create this macro variable. Show us what you are doing after it is created.&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 11:16:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-not-resolving/m-p/877238#M346554</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-24T11:16:41Z</dc:date>
    </item>
  </channel>
</rss>

