<?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: %include question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/include-question/m-p/440041#M282491</link>
    <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Can I create a macro1 with a %include statement referencing macro2 that is stored in&amp;nbsp;macro catalog location?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It depends on if the catalog is available. If you have it in a library that isn't assigned it won't work for example.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I would personally&amp;nbsp;recommend saving each macro into a .sas file and then putting them into a folder. You can then %INCLUDE all macros in that folder using:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%include "C:\_localdata\SASMacros\*.sas";

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Or you can create the&amp;nbsp;auto call library as indicated already. The&amp;nbsp;documentation may seem confusing, but it's quite straightforward. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In that case, you save each macro into a file, with the macro name as the file name. Then specify:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;option sasautos='path to folder with macros';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/139432"&gt;@vseshad&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Can I create a macro1 with a %include statement referencing macro2 that is stored in&amp;nbsp;macro catalog location? Or do I need to store macro2 as a sas file for me to be able to use %include statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;options mstored sasmstore=test;&lt;/P&gt;
&lt;P&gt;libname test "c:/desktop/test";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro macro1/store source;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;proc print data=test;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro macro2;&lt;/P&gt;
&lt;P&gt;%include "c:\desktop\macro1.sas";&amp;nbsp; &amp;lt;----- Is is possible for me to refer to macro1 like this? Or should I save all the above code in a file&amp;nbsp; &amp;nbsp; %mend;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; and refer that file?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&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;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 25 Feb 2018 17:39:51 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-02-25T17:39:51Z</dc:date>
    <item>
      <title>%include question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/include-question/m-p/440002#M282487</link>
      <description>&lt;P&gt;Can I create a macro1 with a %include statement referencing macro2 that is stored in&amp;nbsp;macro catalog location? Or do I need to store macro2 as a sas file for me to be able to use %include statement?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&amp;nbsp;&lt;/P&gt;&lt;P&gt;options mstored sasmstore=test;&lt;/P&gt;&lt;P&gt;libname test "c:/desktop/test";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro macro1/store source;&lt;/P&gt;&lt;P&gt;&amp;nbsp;proc print data=test;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro macro2;&lt;/P&gt;&lt;P&gt;%include "c:\desktop\macro1.sas";&amp;nbsp; &amp;lt;----- Is is possible for me to refer to macro1 like this? Or should I save all the above code in a file&amp;nbsp; &amp;nbsp; %mend;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; and refer that file?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&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>Sun, 25 Feb 2018 05:08:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/include-question/m-p/440002#M282487</guid>
      <dc:creator>vseshad</dc:creator>
      <dc:date>2018-02-25T05:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: %include question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/include-question/m-p/440003#M282488</link>
      <description>&lt;P&gt;If you want to store your macros in separate files then I would highly recommend you set up a macro AUTOCALL library. You don't need to use %INCLUDE with these at all - SAS will search for them automatically:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n1o5fkxq0gqdpcn1xs3ksdks69tf.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;http://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n1o5fkxq0gqdpcn1xs3ksdks69tf.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Feb 2018 05:50:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/include-question/m-p/440003#M282488</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2018-02-25T05:50:57Z</dc:date>
    </item>
    <item>
      <title>Re: %include question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/include-question/m-p/440024#M282489</link>
      <description>&lt;P&gt;Thank you for your reply.&amp;nbsp; I am trying to understand what would be the best way to use %include to refer a macro. I understand from your reply that %include isn't the best solution to refer a stored macro but if I still want to use %include, how would I go about doing it? Thank you again for your reply. Users such as yourself are a huge help to novices like me.&lt;/P&gt;</description>
      <pubDate>Sun, 25 Feb 2018 13:46:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/include-question/m-p/440024#M282489</guid>
      <dc:creator>vseshad</dc:creator>
      <dc:date>2018-02-25T13:46:20Z</dc:date>
    </item>
    <item>
      <title>Re: %include question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/include-question/m-p/440036#M282490</link>
      <description>&lt;P&gt;The %INCLUDE command reads in lines of code. So to "%include" a macro you need have a text file with the SAS code to define the macro.&amp;nbsp; So make a file that looks like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro mymacro 
....
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then in the program where you want have the macro defined you use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%include FILENAME;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;SAS has a lot of ways to refer to source of the text lines, including source members in SAS catalogs. The easiest is just to use a quoted physical file name.&lt;/P&gt;</description>
      <pubDate>Sun, 25 Feb 2018 16:57:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/include-question/m-p/440036#M282490</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-02-25T16:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: %include question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/include-question/m-p/440041#M282491</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Can I create a macro1 with a %include statement referencing macro2 that is stored in&amp;nbsp;macro catalog location?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It depends on if the catalog is available. If you have it in a library that isn't assigned it won't work for example.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I would personally&amp;nbsp;recommend saving each macro into a .sas file and then putting them into a folder. You can then %INCLUDE all macros in that folder using:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%include "C:\_localdata\SASMacros\*.sas";

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Or you can create the&amp;nbsp;auto call library as indicated already. The&amp;nbsp;documentation may seem confusing, but it's quite straightforward. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In that case, you save each macro into a file, with the macro name as the file name. Then specify:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;option sasautos='path to folder with macros';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/139432"&gt;@vseshad&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Can I create a macro1 with a %include statement referencing macro2 that is stored in&amp;nbsp;macro catalog location? Or do I need to store macro2 as a sas file for me to be able to use %include statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;options mstored sasmstore=test;&lt;/P&gt;
&lt;P&gt;libname test "c:/desktop/test";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro macro1/store source;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;proc print data=test;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro macro2;&lt;/P&gt;
&lt;P&gt;%include "c:\desktop\macro1.sas";&amp;nbsp; &amp;lt;----- Is is possible for me to refer to macro1 like this? Or should I save all the above code in a file&amp;nbsp; &amp;nbsp; %mend;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; and refer that file?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&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;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Feb 2018 17:39:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/include-question/m-p/440041#M282491</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-25T17:39:51Z</dc:date>
    </item>
    <item>
      <title>Re: %include question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/include-question/m-p/440149#M282492</link>
      <description>&lt;P&gt;Thank you Reeza. I understand this a lot better now&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2018 11:05:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/include-question/m-p/440149#M282492</guid>
      <dc:creator>vseshad</dc:creator>
      <dc:date>2018-02-26T11:05:08Z</dc:date>
    </item>
  </channel>
</rss>

