<?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: how to call a SAS macro function from a Unix terminal in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-call-a-SAS-macro-function-from-a-Unix-terminal/m-p/939512#M45138</link>
    <description>&lt;P&gt;An example of an autocall macro:&lt;/P&gt;
&lt;P&gt;Run this from your editor:&lt;/P&gt;
&lt;PRE&gt;%colormac;&lt;/PRE&gt;
&lt;P&gt;The log will likely show something like&lt;/P&gt;
&lt;PRE&gt;NOTE: The macro COLORMAC completed compilation without errors.
      59 instructions 1648 bytes.
NOTE: The macro RGB completed compilation without errors.
      19 instructions 440 bytes.
NOTE: The macro HLS completed compilation without errors.
      59 instructions 1180 bytes.

&lt;/PRE&gt;
&lt;P&gt;Then run this code:&lt;/P&gt;
&lt;PRE&gt;proc options option=set;
run;&lt;/PRE&gt;
&lt;P&gt;You will likely see something like this in the log:&lt;/P&gt;
&lt;PRE&gt; SET=[FT15F001 = 'FT15F001.DAT'] [SASROOT = "C:\Program Files\SASHome\SASFoundation\9.4"]
[SASHOME = "C:\Program Files\SASHome"] [&lt;FONT color="#0000FF"&gt;&lt;U&gt;SASAUTOS = (                    "!SASROOT\core\sasmacro"
        "!SASROOT\aacomp\sasmacro"          "!SASROOT\accelmva\sasmacro"
"!SASROOT\dmscore\sasmacro"          "!SASROOT\graph\sasmacro"          "!SASROOT\hps\sasmacro"
       "!SASROOT\mlearning\sasmacro"          "!SASROOT\stat\sasmacro"          )&lt;/U&gt;&lt;/FONT&gt;] [SAMPSIO = (
                 "!SASROOT\core\sample"          "!SASROOT\access\sample"
"!SASROOT\accesssample\sample"          "!SASROOT\graph\sample"          "!SASROOT\hps\sample"
      "!SASROOT\hpstat\sample"          "!SASROOT\stat\sample"          )] [SAMPsrc=(
         "!SASROOT\core\sample"          "!SASROOT\access\sample"
"!SASROOT\accesssample\sample"          "!SASROOT\graph\sample"          "!SASROOT\hps\sample"
      "!SASROOT\hpstat\sample"          "!SASROOT\stat\sample"          )] [INSTALL = (
         )] [MYSASFILES = "?FOLDERID_Documents\My SAS Files\9.4"] [SASCFG = "C:\Program
Files\SASHome\SASFoundation\9.4\nls\en"] [SAS_NO_RANDOM_ACCESS = "1"] [SAS_ODSG_CRENDER_PATH =
"C:\Program Files\SASHome\SASODSGraphicsCRenderer\9.46"]
                   Defines a SAS environment variable.

&lt;/PRE&gt;
&lt;P&gt;The part underlined and highlighted in blue above relates to the SAS supplied macro definitions. !SASROOT is an environment variable where SAS is installed and the rest is the path from there to the folders containing macros.&lt;/P&gt;
&lt;P&gt;If you run some code like this with a valid drive/folder replacing my C:\somefolder\subfolder&lt;/P&gt;
&lt;PRE&gt;options insert=(SASAUTOS=("c:\somefolder\subfolder")) ;&lt;/PRE&gt;
&lt;P&gt;and rerun the Proc options above you will see your folder in the list of SASAUTOS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any macro placed in that folder where the name of the file and the macro have the same name: i.e. the file named&lt;/P&gt;
&lt;P&gt;Mymacro.sas and the first program lines other than comments are "%macro mymacro ("&lt;/P&gt;
&lt;P&gt;Whenever you us %mymacro in your code if you have not compiled the macro in the current session then SAS will look in the folders listed in the SASAUTOS for a file named Mymacro.sas and compile it when needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have an options statement in my AUTOEXEC.SAS file that executes whenever SAS starts to set this option (among several other options, library definitions and %include a couple of other program files I want to execute each time SAS starts). There are other ways.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Aug 2024 20:36:51 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2024-08-15T20:36:51Z</dc:date>
    <item>
      <title>how to call a SAS macro function from a Unix terminal</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-call-a-SAS-macro-function-from-a-Unix-terminal/m-p/939507#M45134</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to know, from a Unix terminal window, which command can I use to execute the macro function test?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test;
libname dest1 "/.../dataretention/reports";

data dest1.class;
set sashelp.class;
run;
%mend test;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test1;
libname dest1 "/.../dataretention/reports";

data dest1.class;
set sashelp.class;
run;
%mend test1;
%test1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the call for test1 from a Unix terminal will be: sas test1.sas&lt;/P&gt;
&lt;P&gt;But it there a way to execute / call test.sas&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 19:56:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-call-a-SAS-macro-function-from-a-Unix-terminal/m-p/939507#M45134</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2024-08-15T19:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to call a SAS macro function from a Unix terminal</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-call-a-SAS-macro-function-from-a-Unix-terminal/m-p/939509#M45135</link>
      <description>&lt;P&gt;You would use UNIX commands to start SAS and provide the file with the macro code and other statements as the program script to run.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the program only has the code for macro test and no call to the macro then you are wasting computer clock cycles as all that wold happen is the compilation of the macro. The macro define this was does not persist or exist outside of that specific SAS session.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the real objective you are attempting to do. There are ways to make macro code available such as AUTOCALL libraries such as SAS uses to store the SAS supplied macros that you can use.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 19:59:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-call-a-SAS-macro-function-from-a-Unix-terminal/m-p/939509#M45135</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-08-15T19:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to call a SAS macro function from a Unix terminal</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-call-a-SAS-macro-function-from-a-Unix-terminal/m-p/939510#M45136</link>
      <description>&lt;P&gt;I am exploring the various options.&amp;nbsp; Could you please provide more information on autocall libraries . Please provide an example&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 20:08:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-call-a-SAS-macro-function-from-a-Unix-terminal/m-p/939510#M45136</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2024-08-15T20:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: how to call a SAS macro function from a Unix terminal</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-call-a-SAS-macro-function-from-a-Unix-terminal/m-p/939511#M45137</link>
      <description>&lt;P&gt;The &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lesysoptsref/n16z79lqkz4a87n1urzo6mithnza.htm" target="_blank" rel="noopener"&gt;INITSTMT system option&lt;/A&gt; may be helpful here:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;sas -initstmt '%include "test.sas"; %test;'&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Aug 2024 20:08:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-call-a-SAS-macro-function-from-a-Unix-terminal/m-p/939511#M45137</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2024-08-15T20:08:52Z</dc:date>
    </item>
    <item>
      <title>Re: how to call a SAS macro function from a Unix terminal</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-call-a-SAS-macro-function-from-a-Unix-terminal/m-p/939512#M45138</link>
      <description>&lt;P&gt;An example of an autocall macro:&lt;/P&gt;
&lt;P&gt;Run this from your editor:&lt;/P&gt;
&lt;PRE&gt;%colormac;&lt;/PRE&gt;
&lt;P&gt;The log will likely show something like&lt;/P&gt;
&lt;PRE&gt;NOTE: The macro COLORMAC completed compilation without errors.
      59 instructions 1648 bytes.
NOTE: The macro RGB completed compilation without errors.
      19 instructions 440 bytes.
NOTE: The macro HLS completed compilation without errors.
      59 instructions 1180 bytes.

&lt;/PRE&gt;
&lt;P&gt;Then run this code:&lt;/P&gt;
&lt;PRE&gt;proc options option=set;
run;&lt;/PRE&gt;
&lt;P&gt;You will likely see something like this in the log:&lt;/P&gt;
&lt;PRE&gt; SET=[FT15F001 = 'FT15F001.DAT'] [SASROOT = "C:\Program Files\SASHome\SASFoundation\9.4"]
[SASHOME = "C:\Program Files\SASHome"] [&lt;FONT color="#0000FF"&gt;&lt;U&gt;SASAUTOS = (                    "!SASROOT\core\sasmacro"
        "!SASROOT\aacomp\sasmacro"          "!SASROOT\accelmva\sasmacro"
"!SASROOT\dmscore\sasmacro"          "!SASROOT\graph\sasmacro"          "!SASROOT\hps\sasmacro"
       "!SASROOT\mlearning\sasmacro"          "!SASROOT\stat\sasmacro"          )&lt;/U&gt;&lt;/FONT&gt;] [SAMPSIO = (
                 "!SASROOT\core\sample"          "!SASROOT\access\sample"
"!SASROOT\accesssample\sample"          "!SASROOT\graph\sample"          "!SASROOT\hps\sample"
      "!SASROOT\hpstat\sample"          "!SASROOT\stat\sample"          )] [SAMPsrc=(
         "!SASROOT\core\sample"          "!SASROOT\access\sample"
"!SASROOT\accesssample\sample"          "!SASROOT\graph\sample"          "!SASROOT\hps\sample"
      "!SASROOT\hpstat\sample"          "!SASROOT\stat\sample"          )] [INSTALL = (
         )] [MYSASFILES = "?FOLDERID_Documents\My SAS Files\9.4"] [SASCFG = "C:\Program
Files\SASHome\SASFoundation\9.4\nls\en"] [SAS_NO_RANDOM_ACCESS = "1"] [SAS_ODSG_CRENDER_PATH =
"C:\Program Files\SASHome\SASODSGraphicsCRenderer\9.46"]
                   Defines a SAS environment variable.

&lt;/PRE&gt;
&lt;P&gt;The part underlined and highlighted in blue above relates to the SAS supplied macro definitions. !SASROOT is an environment variable where SAS is installed and the rest is the path from there to the folders containing macros.&lt;/P&gt;
&lt;P&gt;If you run some code like this with a valid drive/folder replacing my C:\somefolder\subfolder&lt;/P&gt;
&lt;PRE&gt;options insert=(SASAUTOS=("c:\somefolder\subfolder")) ;&lt;/PRE&gt;
&lt;P&gt;and rerun the Proc options above you will see your folder in the list of SASAUTOS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any macro placed in that folder where the name of the file and the macro have the same name: i.e. the file named&lt;/P&gt;
&lt;P&gt;Mymacro.sas and the first program lines other than comments are "%macro mymacro ("&lt;/P&gt;
&lt;P&gt;Whenever you us %mymacro in your code if you have not compiled the macro in the current session then SAS will look in the folders listed in the SASAUTOS for a file named Mymacro.sas and compile it when needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have an options statement in my AUTOEXEC.SAS file that executes whenever SAS starts to set this option (among several other options, library definitions and %include a couple of other program files I want to execute each time SAS starts). There are other ways.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 20:36:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-call-a-SAS-macro-function-from-a-Unix-terminal/m-p/939512#M45138</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-08-15T20:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to call a SAS macro function from a Unix terminal</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-call-a-SAS-macro-function-from-a-Unix-terminal/m-p/939537#M45139</link>
      <description>&lt;P&gt;I don't understand the question.&amp;nbsp; If you have a program test.sas with contents:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test;
libname dest1 "/.../dataretention/reports";

data dest1.class;
set sashelp.class;
run;
%mend test;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can execute that program with:&amp;nbsp;&lt;SPAN&gt;sas test.sas.&amp;nbsp; And that will execute the program, which will compile the macro named TEST and then the SAS session will exit successfully.&amp;nbsp; But it won't execute the macro, because you never called the macro.&lt;BR /&gt;&lt;BR /&gt;If you have a program test2.sas with contents:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%test()&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Then you could run that program with: sas test2.sas.&amp;nbsp; And that will execute the macro TEST.&amp;nbsp; If it can find a macro named TEST in an autocall library it will execute.&amp;nbsp; If it can't find macro named TEST it will generate an error.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 00:40:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-call-a-SAS-macro-function-from-a-Unix-terminal/m-p/939537#M45139</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-08-16T00:40:42Z</dc:date>
    </item>
  </channel>
</rss>

