<?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: Issue when calling Macro in a physical file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Issue-when-calling-Macro-in-a-physical-file/m-p/650610#M195106</link>
    <description>&lt;P&gt;Looks like your .sas file lacks the %macro keyword.&lt;/P&gt;</description>
    <pubDate>Tue, 26 May 2020 06:58:03 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-05-26T06:58:03Z</dc:date>
    <item>
      <title>Issue when calling Macro in a physical file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-when-calling-Macro-in-a-physical-file/m-p/650606#M195104</link>
      <description>&lt;P&gt;I first developed a Macro script in SAS EG, which will update a set of records into a SAS BASE Table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I then make this a Macro Script dynamic that will take in parameter based on every session. I stored this Macro script as .sas file in the physical path in the server.&lt;/P&gt;&lt;P&gt;(Assume it is /sasapp/macro).&lt;/P&gt;&lt;P&gt;The screenshot for this script(&lt;STRONG&gt;I cant copy the script out because the server doesnt allow us to copy paste&lt;/STRONG&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="EdS2KcK" style="width: 647px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/39959iDB33D66F01991FC8/image-size/large?v=v2&amp;amp;px=999" role="button" title="EdS2KcK" alt="EdS2KcK" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="juex43G" style="width: 659px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/39960i06FEAE50A3181583/image-size/large?v=v2&amp;amp;px=999" role="button" title="juex43G" alt="juex43G" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works perfectly fine when i run the script in SAS EG.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I configured SASAUTOS in sasv9.cfg to include SAS Auto Macro in this directory. However, even after configuring and restarting objectspawner, it is not taking effect for this new directory. My plan is that I set to trigger this macro.sas everytime i run a job in SAS DI Studio.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To further troubleshoot, I re-trigger/re-run in the original sas macro script using SAS EG, It works. However, when i try the command below, It doesn't work. Now, I am not sure what is wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename ptmacro '/sasapp/macro/jobctrl.sas';
%include ptmacro;

%startjob(1, test, started);&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;The error that I am getting:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rXmg7Nm" style="width: 950px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/39958i1D8CAF9C5F7D4F04/image-size/large?v=v2&amp;amp;px=999" role="button" title="rXmg7Nm" alt="rXmg7Nm" /&gt;&lt;/span&gt;&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;My question is, why running %startjob in the original full macro script works in SAS EG, but if i use %include in a new SAS Session and try to trigger with %startjob (without full macro script this time), it gives error.&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2020 06:35:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-when-calling-Macro-in-a-physical-file/m-p/650606#M195104</guid>
      <dc:creator>WorkingMan</dc:creator>
      <dc:date>2020-05-26T06:35:23Z</dc:date>
    </item>
    <item>
      <title>Re: Issue when calling Macro in a physical file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-when-calling-Macro-in-a-physical-file/m-p/650610#M195106</link>
      <description>&lt;P&gt;Looks like your .sas file lacks the %macro keyword.&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2020 06:58:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-when-calling-Macro-in-a-physical-file/m-p/650610#M195106</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-26T06:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: Issue when calling Macro in a physical file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-when-calling-Macro-in-a-physical-file/m-p/650612#M195108</link>
      <description>&lt;P&gt;If extending SASAUTOS either in a .cfg or an autoexec make sure you add this to the one with &lt;EM&gt;usermods&lt;/EM&gt; in the name. You are not supposed to change the other ones and applying a SAS patch or upgrade will potentially overwrite them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The filename of your autocall macro must be all lowercase and it must be the name of your macro. So if your macro is called %startjob() then the filename must be startjob.sas&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the sample code you've posted: The included file is jobctrl.sas - why would this compile macro %startjob()?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2020 07:01:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-when-calling-Macro-in-a-physical-file/m-p/650612#M195108</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-05-26T07:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: Issue when calling Macro in a physical file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-when-calling-Macro-in-a-physical-file/m-p/650613#M195109</link>
      <description>Hi Kurt, did u mean&lt;BR /&gt;%macro startjob( );&lt;BR /&gt;in the .sas file?&lt;BR /&gt;&lt;BR /&gt;I have that...the .sas script has the same exact script as my EG body</description>
      <pubDate>Tue, 26 May 2020 07:03:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-when-calling-Macro-in-a-physical-file/m-p/650613#M195109</guid>
      <dc:creator>WorkingMan</dc:creator>
      <dc:date>2020-05-26T07:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: Issue when calling Macro in a physical file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-when-calling-Macro-in-a-physical-file/m-p/650615#M195111</link>
      <description>&lt;P&gt;Wait...&lt;/P&gt;
&lt;P&gt;did you put this into your AUTOCALL folder? If you want to use the SAS AUTOCALL facility, the name of the macro must be identical to the name of the SAS file. So if your macro is called startjob, the file must be saved as startjob.sas in the AUTOCALL facility.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise, your code must work:&lt;/P&gt;
&lt;P&gt;I created this program:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro startjob(JOBID,ETLS_JOBNAME,STATUS);
%put &amp;amp;=JOBID;
%PUT &amp;amp;=ETLS_JOBNAME;
%put &amp;amp;=STATUS;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and saved in as jobctrl.sas in my /folders/myfolders in SAS University Edition.&lt;/P&gt;
&lt;P&gt;Then I ran this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename ptmacro '/folders/myfolders/jobctrl.sas';
%include ptmacro;

%startjob(1,test,started)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and got this log:&lt;/P&gt;
&lt;PRE&gt; 73         filename ptmacro '/folders/myfolders/jobctrl.sas';
 74         %include ptmacro;
 80         
 81         %startjob(1,test,started)
 JOBID=1
 ETLS_JOBNAME=test
 STATUS=started
 82         
&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 May 2020 07:17:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-when-calling-Macro-in-a-physical-file/m-p/650615#M195111</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-26T07:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: Issue when calling Macro in a physical file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-when-calling-Macro-in-a-physical-file/m-p/650620#M195113</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;. I followed your advice by renaming my file name to startjob.sas&lt;/P&gt;&lt;P&gt;Miraculously, it is able to read the folder that stores the macro script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I am now hitting a new error :&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dbou9tl" style="width: 630px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/39961iB9E502B0439B363E/image-size/large?v=v2&amp;amp;px=999" role="button" title="dbou9tl" alt="dbou9tl" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the only error in DI job....What is wrong with this? I dont see anything wrong...just weird to me.&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2020 07:36:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-when-calling-Macro-in-a-physical-file/m-p/650620#M195113</guid>
      <dc:creator>WorkingMan</dc:creator>
      <dc:date>2020-05-26T07:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: Issue when calling Macro in a physical file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-when-calling-Macro-in-a-physical-file/m-p/650626#M195116</link>
      <description>&lt;P&gt;If you extended your AUTOCALL configuration for the Workspace Server, you must also include this change for the Data Step Batch Server. Or (still better) make the change in the parent directory of both (usually SASApp).&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2020 08:15:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-when-calling-Macro-in-a-physical-file/m-p/650626#M195116</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-26T08:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: Issue when calling Macro in a physical file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-when-calling-Macro-in-a-physical-file/m-p/650627#M195117</link>
      <description>&lt;P&gt;I normally debug such DIS code using EG - just copy the code from DIS from top until this line of code. Set options mprint mlogic and then execute and fix the code.&lt;/P&gt;
&lt;P&gt;There is either something wrong in your macro code or may-be you just need an %unquote(&amp;amp;jobid).&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2020 08:15:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-when-calling-Macro-in-a-physical-file/m-p/650627#M195117</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-05-26T08:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: Issue when calling Macro in a physical file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-when-calling-Macro-in-a-physical-file/m-p/650924#M195226</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/189060"&gt;@WorkingMan&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;. I followed your advice by renaming my file name to startjob.sas&lt;/P&gt;
&lt;P&gt;Miraculously, it is able to read the folder that stores the macro script.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I am now hitting a new error :&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dbou9tl" style="width: 630px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/39961iB9E502B0439B363E/image-size/large?v=v2&amp;amp;px=999" role="button" title="dbou9tl" alt="dbou9tl" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the only error in DI job....What is wrong with this? I dont see anything wrong...just weird to me.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What is the value of the macro variable &amp;amp;Jobid at this time?&lt;/P&gt;
&lt;P&gt;Debugging macros means setting the system options MPRINT and often SYMBOLGEN to see the code generated/submitted. And you may want SOURCE2 to show that the %include file is used properly.&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2020 21:28:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-when-calling-Macro-in-a-physical-file/m-p/650924#M195226</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-05-26T21:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: Issue when calling Macro in a physical file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-when-calling-Macro-in-a-physical-file/m-p/650983#M195253</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;jobid is a SAS Data Integration Studio generated and populated macro variable. It's always at the very beginning of the generated SAS code and contains the SAS Metadata ID to the DIS job metadata definition used to generate the SAS code from.&lt;/P&gt;</description>
      <pubDate>Wed, 27 May 2020 06:27:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-when-calling-Macro-in-a-physical-file/m-p/650983#M195253</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-05-27T06:27:13Z</dc:date>
    </item>
  </channel>
</rss>

