<?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 invocation in %PUT statement (in macro definition VS. in open code) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-invocation-in-PUT-statement-in-macro-definition-VS-in-open/m-p/130878#M26691</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Amir!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the same thought too, but didn't find any proof in the Help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 01 Nov 2013 13:06:01 GMT</pubDate>
    <dc:creator>pobel</dc:creator>
    <dc:date>2013-11-01T13:06:01Z</dc:date>
    <item>
      <title>macro invocation in %PUT statement (in macro definition VS. in open code)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-invocation-in-PUT-statement-in-macro-definition-VS-in-open/m-p/130876#M26689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please take a look at the following code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="289" style="border: 1px solid rgb(0, 0, 0); width: 254px; height: 276px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Program&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;P&gt;%macro a;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; part1; part2&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro b;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %put *%a*;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*** Try 1;&lt;/P&gt;&lt;P&gt;%b&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*** Try 2;&lt;/P&gt;&lt;P&gt;%put *%a*;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the result in the log:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="54" style="border: 1px solid rgb(0, 0, 0); width: 493px; height: 56px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Log&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;P&gt;10&amp;nbsp;&amp;nbsp; %b;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #800000;"&gt;*part1; part2*&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;11&lt;/P&gt;&lt;P&gt;12&amp;nbsp;&amp;nbsp; %put *%a*;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #800000;"&gt;&lt;STRONG&gt;*part1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;NOTE: Line generated by the invoked macro "A".&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; part1; part2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -----&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 180&lt;/P&gt;&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The same %PUT statement acts differently in the open code than in a macro definition.&lt;/P&gt;&lt;P&gt;In the open code, the semicolon between 'part1' and 'part2' was treated as the end of the %PUT statement. Just like when we directly submit "%put *part1; part2*;".&lt;/P&gt;&lt;P&gt;However, when the %PUT statement was in a macro program, the semicolon returned by "%a" was treated as a plain character.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would anyone please explain this difference for me? I didn't find the answer from the HELP documentation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot in advance!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Nov 2013 05:49:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-invocation-in-PUT-statement-in-macro-definition-VS-in-open/m-p/130876#M26689</guid>
      <dc:creator>pobel</dc:creator>
      <dc:date>2013-11-01T05:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: macro invocation in %PUT statement (in macro definition VS. in open code)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-invocation-in-PUT-statement-in-macro-definition-VS-in-open/m-p/130877#M26690</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Interesting question, I can see that:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put %quote(*%a*);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;produces the desired result, making me think it is to do with macro quoting which is a large topic:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/62978/HTML/default/viewer.htm#p07u5itr1teq0dn1bx0lli1ri5dy.htm" title="http://support.sas.com/documentation/cdl/en/mcrolref/62978/HTML/default/viewer.htm#p07u5itr1teq0dn1bx0lli1ri5dy.htm"&gt;SAS(R) 9.3 Macro Language: Reference&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Nov 2013 12:17:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-invocation-in-PUT-statement-in-macro-definition-VS-in-open/m-p/130877#M26690</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2013-11-01T12:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: macro invocation in %PUT statement (in macro definition VS. in open code)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-invocation-in-PUT-statement-in-macro-definition-VS-in-open/m-p/130878#M26691</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Amir!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the same thought too, but didn't find any proof in the Help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Nov 2013 13:06:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-invocation-in-PUT-statement-in-macro-definition-VS-in-open/m-p/130878#M26691</guid>
      <dc:creator>pobel</dc:creator>
      <dc:date>2013-11-01T13:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: macro invocation in %PUT statement (in macro definition VS. in open code)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-invocation-in-PUT-statement-in-macro-definition-VS-in-open/m-p/130879#M26692</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is simpler than that.&lt;/P&gt;&lt;P&gt;The macro executes and generates text which is assumed to be valid syntax inopen code&lt;/P&gt;&lt;P&gt;When the text generated is a string it can resolve within " double quotes. However it must be valid code wherever the&amp;nbsp;&amp;nbsp; macro executes .&lt;/P&gt;&lt;P&gt;When your macro executes it generates statements that might be valid inside a data step but which are not valid outside a data step. &lt;/P&gt;&lt;P&gt;It's not the macro at fault but its usage.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 03 Nov 2013 22:29:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-invocation-in-PUT-statement-in-macro-definition-VS-in-open/m-p/130879#M26692</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2013-11-03T22:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: macro invocation in %PUT statement (in macro definition VS. in open code)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-invocation-in-PUT-statement-in-macro-definition-VS-in-open/m-p/130880#M26693</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Peter.C!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I cannot understand is:&amp;nbsp; why the returned code of a macro, when this macro was invoked inside another macro, was masked (the returned semicolon was not treated as the end of a statement).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If we add another %PUT statement in the macro A:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="310" style="border: 1px solid rgb(0, 0, 0); width: 347px; height: 312px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Program&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;P&gt;%macro a;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; part1; part2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #800000;"&gt;&lt;STRONG&gt;%put This is when macro A execue.;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro b;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %put *%a*;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*** Try 1;&lt;/P&gt;&lt;P&gt;%b&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*** Try 2;&lt;/P&gt;&lt;P&gt;%put *%a*;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="261" style="border: 1px solid rgb(0, 0, 0); width: 503px; height: 263px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Log&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;P&gt;19&amp;nbsp;&amp;nbsp; %b&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #800000;"&gt;&lt;STRONG&gt;This is when macro A execue&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;*part1; part2*&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;20&amp;nbsp;&amp;nbsp; %put *%a*;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;*part1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #800000;"&gt;&lt;STRONG&gt;This is when macro A execue&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;NOTE: Line generated by the invoked macro "A".&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; part1; part2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -----&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 180&lt;/P&gt;&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;We can see from the log that when macro B executes, the execution of macro A was before B's %PUT statement. So I am guessing maybe there's an automatic quoting when a macro was invoked inside another macro definition. But I am not sure whether this guess is right or not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Nov 2013 01:14:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-invocation-in-PUT-statement-in-macro-definition-VS-in-open/m-p/130880#M26693</guid>
      <dc:creator>pobel</dc:creator>
      <dc:date>2013-11-04T01:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: macro invocation in %PUT statement (in macro definition VS. in open code)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-invocation-in-PUT-statement-in-macro-definition-VS-in-open/m-p/130881#M26694</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You've noticed something, but our explanations can only be a "best guess".&amp;nbsp; We're seeing inputs and outputs, but not the process.&amp;nbsp; Here's my interpretation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This has nothing to do with macro quoting, but has to do with the process of compiling a macro.&amp;nbsp; As part of the macro compilation process, macro language interprets the semicolon it can "see" (at the end of the %PUT statement) as ending the %PUT statement.&amp;nbsp; The introduction of a semicolon within %A does not change that interpretation.&amp;nbsp; In open code, however, the first semicolon ends the first statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Nov 2013 02:53:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-invocation-in-PUT-statement-in-macro-definition-VS-in-open/m-p/130881#M26694</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-11-04T02:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: macro invocation in %PUT statement (in macro definition VS. in open code)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-invocation-in-PUT-statement-in-macro-definition-VS-in-open/m-p/130882#M26695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, Astounding!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your explanation is very helpful. Thank you very much on this one!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Nov 2013 03:38:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-invocation-in-PUT-statement-in-macro-definition-VS-in-open/m-p/130882#M26695</guid>
      <dc:creator>pobel</dc:creator>
      <dc:date>2013-11-04T03:38:25Z</dc:date>
    </item>
  </channel>
</rss>

