<?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 source code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-source-code/m-p/301006#M63651</link>
    <description>&lt;P&gt;It's unfortunately not a "one stop shop" if you really want to figure out where your SAS code picks up a macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you call a macro in your SAS program, SAS follows a search path to find the macro. The first location a macro with the name you've been calling is found, is the code which gets used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macros used in SAS code are compiled; but there is a SAS Autocall facility which allows you to call a macro which hasn't been previously compiled. Such a macro then gets compiled into a catalog in WORK. Any subsequent call of this macro then sources it directly from the catalog in WORK (=compile once, use multiple times).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you set option "&lt;SPAN&gt;MAUTOLOCDISPLAY" in your SAS session then SAS will write to the log for such cases where it picked up&amp;nbsp;the macro code for compilation into WORK.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It's documented somewhere in the SAS Macro documentation (or SAS Concepts?) but off&amp;nbsp;the top of my head the search path is:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1. macro catalog in WORK&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2. macro catalog defined in SOURCE&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;3. search path as defined in option SASAUTOS&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; you can list the full path using the code as available here:&amp;nbsp;&lt;A href="http://support.sas.com/kb/42/654.html" target="_blank"&gt;http://support.sas.com/kb/42/654.html&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Hope that helped,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Patrick&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 27 Sep 2016 12:04:34 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2016-09-27T12:04:34Z</dc:date>
    <item>
      <title>Macro source code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-source-code/m-p/300968#M63627</link>
      <description>&lt;P&gt;I have a macro called "mymacro". When I am calling it, it works well, but I want to find where this macro code is actually saved?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way to find it out.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2016 09:43:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-source-code/m-p/300968#M63627</guid>
      <dc:creator>RahulG</dc:creator>
      <dc:date>2016-09-27T09:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: Macro source code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-source-code/m-p/300970#M63628</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;use macro options - mprint, symbolgen, mlogic to see the code generated by the macro.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2016 09:49:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-source-code/m-p/300970#M63628</guid>
      <dc:creator>Loko</dc:creator>
      <dc:date>2016-09-27T09:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: Macro source code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-source-code/m-p/300975#M63630</link>
      <description>&lt;P&gt;The macro code is not 'saved' it is only compiled in your work directory.&lt;/P&gt;&lt;P&gt;You can store text that is generated by the macro facility during macro execution in an external file. (useful for debugging macros) with &lt;SPAN class="ms-rteStyle-Accent1"&gt;​options mfile mprint;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2016 09:55:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-source-code/m-p/300975#M63630</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2016-09-27T09:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: Macro source code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-source-code/m-p/300981#M63634</link>
      <description>&lt;P&gt;It depends on how the macro is included. &amp;nbsp;In your program or setup/autoexec.sas there will be a call to sasautos. &amp;nbsp;This gives paths or libnames to where macros are stored. &amp;nbsp;You can also include other files using %include "...\&amp;lt;file&amp;gt;.sas"; So there are a few places where the code can be included. &amp;nbsp;Also note that if the macros are compiled, i.e. to catalogs, then you may not be able to see the code at all - this is called a black box where you can't see the workings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suppose the question here is why do you have a macro and not know where it is?&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2016 10:10:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-source-code/m-p/300981#M63634</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-09-27T10:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: Macro source code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-source-code/m-p/300986#M63637</link>
      <description>&lt;P&gt;If stored in a catalog try %copy to see code in your log.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%copy macro_name;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise look at&amp;nbsp;MAUTOLOCDISPLAY and/or SASAUTOS option via getoption() function.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put %sysfunc(getoption(Option_Name));&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2016 10:53:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-source-code/m-p/300986#M63637</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-27T10:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: Macro source code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-source-code/m-p/301006#M63651</link>
      <description>&lt;P&gt;It's unfortunately not a "one stop shop" if you really want to figure out where your SAS code picks up a macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you call a macro in your SAS program, SAS follows a search path to find the macro. The first location a macro with the name you've been calling is found, is the code which gets used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macros used in SAS code are compiled; but there is a SAS Autocall facility which allows you to call a macro which hasn't been previously compiled. Such a macro then gets compiled into a catalog in WORK. Any subsequent call of this macro then sources it directly from the catalog in WORK (=compile once, use multiple times).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you set option "&lt;SPAN&gt;MAUTOLOCDISPLAY" in your SAS session then SAS will write to the log for such cases where it picked up&amp;nbsp;the macro code for compilation into WORK.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It's documented somewhere in the SAS Macro documentation (or SAS Concepts?) but off&amp;nbsp;the top of my head the search path is:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1. macro catalog in WORK&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2. macro catalog defined in SOURCE&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;3. search path as defined in option SASAUTOS&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; you can list the full path using the code as available here:&amp;nbsp;&lt;A href="http://support.sas.com/kb/42/654.html" target="_blank"&gt;http://support.sas.com/kb/42/654.html&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Hope that helped,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Patrick&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2016 12:04:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-source-code/m-p/301006#M63651</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-09-27T12:04:34Z</dc:date>
    </item>
  </channel>
</rss>

