<?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: Calling an uncompiled macro to automatically populate the path in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calling-an-uncompiled-macro-to-automatically-populate-the-path/m-p/680484#M205667</link>
    <description>&lt;P&gt;thank you this worked.&lt;/P&gt;</description>
    <pubDate>Mon, 31 Aug 2020 16:56:09 GMT</pubDate>
    <dc:creator>Kc2</dc:creator>
    <dc:date>2020-08-31T16:56:09Z</dc:date>
    <item>
      <title>Calling an uncompiled macro to automatically populate the path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calling-an-uncompiled-macro-to-automatically-populate-the-path/m-p/680430#M205636</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a macro call at the start of my program. This macro is stored in my study folder:&lt;/P&gt;
&lt;P&gt;C:Project\Study\Test\grabpath.sas&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro grabpath;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;%global gpath;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %let gpth= %sysget(SAS_EXECFILEPATH);&lt;BR /&gt;%mend grabpath;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At the start of my program, the macro is called:&lt;/P&gt;
&lt;P&gt;%grabpath;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;it does not work because the macro is not compiled.&lt;/P&gt;
&lt;P&gt;Is there a way to compile the macro when it is called so that with &amp;amp;gpath return the directory path so that the path is not required to be entered manually?&lt;/P&gt;
&lt;P&gt;so thta is I wnat to call the setup.sas file I only write&lt;/P&gt;
&lt;P&gt;%include "&amp;amp;gpath/setup.sas"&amp;nbsp; instead of %include "C:Project\Study\Test\setup.sas"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 13:20:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calling-an-uncompiled-macro-to-automatically-populate-the-path/m-p/680430#M205636</guid>
      <dc:creator>Kc2</dc:creator>
      <dc:date>2020-08-31T13:20:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calling an uncompiled macro to automatically populate the path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calling-an-uncompiled-macro-to-automatically-populate-the-path/m-p/680431#M205637</link>
      <description>&lt;P&gt;You could add this statement to the beginning of your program:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options sasautos = ('C:Project\Study\Test' sasautos);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That would make all macros from that folder (including %grabpath) available to the current program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you have already done, you would need to name the entries properly.&amp;nbsp; So grabpath.sas would need to hold the definition of %grabpath.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 13:32:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calling-an-uncompiled-macro-to-automatically-populate-the-path/m-p/680431#M205637</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-08-31T13:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calling an uncompiled macro to automatically populate the path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calling-an-uncompiled-macro-to-automatically-populate-the-path/m-p/680435#M205639</link>
      <description>But if I change the directory name from Test to TestA or TestB, I would need to manually update the program. I would rather not do any manual update.</description>
      <pubDate>Mon, 31 Aug 2020 13:46:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calling-an-uncompiled-macro-to-automatically-populate-the-path/m-p/680435#M205639</guid>
      <dc:creator>Kc2</dc:creator>
      <dc:date>2020-08-31T13:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: Calling an uncompiled macro to automatically populate the path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calling-an-uncompiled-macro-to-automatically-populate-the-path/m-p/680440#M205640</link>
      <description>&lt;P&gt;Yes, that's true.&amp;nbsp; SAS doesn't have a function that says, "I moved my macros somewhere else, so find out where I moved them to."&amp;nbsp; However, you could just identify a bunch of folders in all your programs if that would work for you:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options sasautos=('C:\Project\Study\Test' 'C:\Project\Study\TestA' 'C:\Project\Study\TestB' sasautos);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Aug 2020 14:15:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calling-an-uncompiled-macro-to-automatically-populate-the-path/m-p/680440#M205640</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-08-31T14:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: Calling an uncompiled macro to automatically populate the path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calling-an-uncompiled-macro-to-automatically-populate-the-path/m-p/680444#M205643</link>
      <description>&lt;P&gt;One alternative is to store general utility macros like this, which will be used across projects, outside of a project-specific directory.&amp;nbsp; And your code or config or autoexec or start icon or whatever you want can add that fixed location to the autocall search path.&amp;nbsp; I typically have an autocall search path that starts with a project-specific autocall directory, then the shared utility autocall directory, then SAS-provided locations.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 14:39:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calling-an-uncompiled-macro-to-automatically-populate-the-path/m-p/680444#M205643</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2020-08-31T14:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: Calling an uncompiled macro to automatically populate the path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calling-an-uncompiled-macro-to-automatically-populate-the-path/m-p/680445#M205644</link>
      <description>Do you have an example?</description>
      <pubDate>Mon, 31 Aug 2020 14:53:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calling-an-uncompiled-macro-to-automatically-populate-the-path/m-p/680445#M205644</guid>
      <dc:creator>Kc2</dc:creator>
      <dc:date>2020-08-31T14:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: Calling an uncompiled macro to automatically populate the path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calling-an-uncompiled-macro-to-automatically-populate-the-path/m-p/680453#M205651</link>
      <description>&lt;P&gt;I have directories like:&lt;/P&gt;
&lt;P&gt;C:\Projects\Project1\Code&lt;/P&gt;
&lt;P&gt;C:\Projects\Project1\Code\Macros&lt;/P&gt;
&lt;P&gt;C:\Projects\Project2\Code&lt;/P&gt;
&lt;P&gt;C:\Projects\Project2\Code\Macros&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;C:\Projects\Common\Code&lt;/P&gt;
&lt;P&gt;C:\Projects\Common\Code\Macros&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I put my shared autocall macros in to&amp;nbsp;C:\Projects\Common\Code\Macros.&amp;nbsp; That's where I would put grabpath.sas, because it's used across projects.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On windows, I edit my config file to point to the folder.&amp;nbsp; Even though the config file says don't edit below this line.&amp;nbsp; Because I'm a rebel.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So my config file has a line like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;-SET SASAUTOS (
        "C:\Projects\Common\Code\Macros"        
        "!SASROOT\core\sasmacro"
        "!SASROOT\graph\sasmacro"
        "!SASROOT\iml\sasmacro"
        "!SASROOT\qc\sasmacro"
        "!SASROOT\stat\sasmacro"
        )
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That way every SAS session I start with this config file has my utility autocall library available.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then in a program where the code is stored in a projectN \Code directory, you could call your grabpath macro, and use it to %include your setup code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%grabpath;

%include "&amp;amp;gpath/setup.sas"  ; 

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And assuming setup.sas is just setup-code, it would include a line like below to add the project-specific macro library to the search path:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*add project-specific macro library to front of search path;
options insert=sasautos=("&amp;amp;gpath\Macros") ;

&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;&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;
&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>Mon, 31 Aug 2020 15:25:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calling-an-uncompiled-macro-to-automatically-populate-the-path/m-p/680453#M205651</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2020-08-31T15:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: Calling an uncompiled macro to automatically populate the path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calling-an-uncompiled-macro-to-automatically-populate-the-path/m-p/680484#M205667</link>
      <description>&lt;P&gt;thank you this worked.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 16:56:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calling-an-uncompiled-macro-to-automatically-populate-the-path/m-p/680484#M205667</guid>
      <dc:creator>Kc2</dc:creator>
      <dc:date>2020-08-31T16:56:09Z</dc:date>
    </item>
  </channel>
</rss>

