<?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: where is the problem for this macro variable reference? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/where-is-the-problem-for-this-macro-variable-reference/m-p/361940#M85443</link>
    <description>&lt;P&gt;Try %UNQUOTE()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test1;
    data a;
    a=1;
    put "a long text";
    run;
%mend;
%test1


%let long=%nrbquote(%test1);
%put &amp;amp;long;

options mprint mlogic symbolgen;
%macro test2;
%if &amp;amp;long ne  %then %do;
    data b;
    b=1;
    run;
%end;
 %unquote(&amp;amp;long) 
proc print width=min;
run;
%mend;

%test2;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 26 May 2017 12:41:55 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2017-05-26T12:41:55Z</dc:date>
    <item>
      <title>where is the problem for this macro variable reference?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/where-is-the-problem-for-this-macro-variable-reference/m-p/361845#M85396</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;%macro test1;
    data a;
    a=1;
    put "a long text";
    run;
%mend;
%test1;       * this works;


%let long=%nrbquote(%test1);
%put &amp;amp;long;

options mprint mlogic symbolgen;
%macro test2;
%if &amp;amp;long ne %str( ) %then %do;
    data b;
    b=1;
%end;
 &amp;amp;long  /* problem here, why? */
proc print width=min;
run;
%mend;

%test2;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/9073iE0AFE70FA0D4A2D4/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="log.png" title="log.png" /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was about to check some macros, but happened to find this error while testing, where is the problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2017 03:33:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/where-is-the-problem-for-this-macro-variable-reference/m-p/361845#M85396</guid>
      <dc:creator>ifendo</dc:creator>
      <dc:date>2017-05-26T03:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: where is the problem for this macro variable reference?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/where-is-the-problem-for-this-macro-variable-reference/m-p/361856#M85401</link>
      <description>&lt;P&gt;What happens if you add a semicolon after &amp;amp;long?&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2017 04:17:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/where-is-the-problem-for-this-macro-variable-reference/m-p/361856#M85401</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-26T04:17:15Z</dc:date>
    </item>
    <item>
      <title>Re: where is the problem for this macro variable reference?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/where-is-the-problem-for-this-macro-variable-reference/m-p/361859#M85404</link>
      <description>&lt;P&gt;Thank you, Reeza. I still got the same error if i add a semicolon...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but if i remove the the put "a long text" ,&amp;nbsp;it works, do not know why&lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://communities.sas.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2017 04:31:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/where-is-the-problem-for-this-macro-variable-reference/m-p/361859#M85404</guid>
      <dc:creator>ifendo</dc:creator>
      <dc:date>2017-05-26T04:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: where is the problem for this macro variable reference?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/where-is-the-problem-for-this-macro-variable-reference/m-p/361864#M85407</link>
      <description>&lt;P&gt;&lt;FONT color="#000080"&gt;%macro&lt;/FONT&gt; test1;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;%do;&lt;/FONT&gt;&lt;BR /&gt;data a;&lt;BR /&gt;a=1;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;%&lt;FONT color="#008000"&gt;put a long text; &lt;FONT color="#FF6600"&gt;/*There must be a sign&lt;/FONT&gt; "&lt;FONT color="#FF0000"&gt;%&lt;/FONT&gt;"&lt;FONT color="#FF6600"&gt;*/&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;run;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;%end;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000080"&gt;%mend;&lt;/FONT&gt;&lt;BR /&gt;%test1;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;%let&lt;/FONT&gt; long=%nrbquote(%test1);&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;%put&lt;/FONT&gt; &amp;amp;long;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;options mprint mlogic symbolgen;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000080"&gt;%macro&lt;/FONT&gt; test2;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;%if&lt;/FONT&gt; &amp;amp;long ne &lt;FONT color="#0000FF"&gt;%str&lt;/FONT&gt;( ) &lt;FONT color="#0000FF"&gt;%then %do&lt;/FONT&gt;;&lt;BR /&gt;data b;&lt;BR /&gt;b=1;&lt;BR /&gt;run;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;%end;&lt;/FONT&gt;&lt;BR /&gt;&amp;amp;long /* problem here, why? */&lt;BR /&gt;proc print width=min;&lt;BR /&gt;run;&lt;BR /&gt;&lt;FONT color="#000080"&gt;%mend;&lt;/FONT&gt;&lt;BR /&gt;%test2;&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2017 05:45:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/where-is-the-problem-for-this-macro-variable-reference/m-p/361864#M85407</guid>
      <dc:creator>kanivan51</dc:creator>
      <dc:date>2017-05-26T05:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: where is the problem for this macro variable reference?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/where-is-the-problem-for-this-macro-variable-reference/m-p/361935#M85441</link>
      <description>&lt;P&gt;The contents of &amp;amp;long have been quoted by %NRBQUOTE. &amp;nbsp;That includes the double quotes surrounding "a long text". &amp;nbsp;Evidently, SAS isn't figuring out to unquote those in time to parse the statement correctly. &amp;nbsp;Try replacing this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;long&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead, use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%unquote(&amp;amp;long)&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2017 12:17:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/where-is-the-problem-for-this-macro-variable-reference/m-p/361935#M85441</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-26T12:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: where is the problem for this macro variable reference?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/where-is-the-problem-for-this-macro-variable-reference/m-p/361940#M85443</link>
      <description>&lt;P&gt;Try %UNQUOTE()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test1;
    data a;
    a=1;
    put "a long text";
    run;
%mend;
%test1


%let long=%nrbquote(%test1);
%put &amp;amp;long;

options mprint mlogic symbolgen;
%macro test2;
%if &amp;amp;long ne  %then %do;
    data b;
    b=1;
    run;
%end;
 %unquote(&amp;amp;long) 
proc print width=min;
run;
%mend;

%test2;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 May 2017 12:41:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/where-is-the-problem-for-this-macro-variable-reference/m-p/361940#M85443</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-05-26T12:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: where is the problem for this macro variable reference?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/where-is-the-problem-for-this-macro-variable-reference/m-p/361950#M85447</link>
      <description>&lt;P&gt;The macro quoting introduced by the %NRBQUOTE() function is causing the generated code to not be valid SAS syntax.&lt;/P&gt;
&lt;P&gt;Use the %UNQUOTE() function to remove the macro quoting when you no longer need it.&lt;/P&gt;
&lt;P&gt;Here is a simplier example.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mvar1=put "no macro quoting";
%let mvar2=%nrbquote(put "macro quoting");
data _null_;
 &amp;amp;mvar1;
run;
data _null_;
 &amp;amp;mvar2;
run;
data _null_;
 %unquote(&amp;amp;mvar2);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 May 2017 13:25:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/where-is-the-problem-for-this-macro-variable-reference/m-p/361950#M85447</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-05-26T13:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: where is the problem for this macro variable reference?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/where-is-the-problem-for-this-macro-variable-reference/m-p/361964#M85451</link>
      <description>Thank you very much for the explanation</description>
      <pubDate>Fri, 26 May 2017 14:02:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/where-is-the-problem-for-this-macro-variable-reference/m-p/361964#M85451</guid>
      <dc:creator>ifendo</dc:creator>
      <dc:date>2017-05-26T14:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: where is the problem for this macro variable reference?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/where-is-the-problem-for-this-macro-variable-reference/m-p/361965#M85452</link>
      <description>&lt;P&gt;Thank you all&lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://communities.sas.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2017 14:02:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/where-is-the-problem-for-this-macro-variable-reference/m-p/361965#M85452</guid>
      <dc:creator>ifendo</dc:creator>
      <dc:date>2017-05-26T14:02:38Z</dc:date>
    </item>
  </channel>
</rss>

