<?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 running batch file from windows in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/running-batch-file-from-windows/m-p/154383#M40557</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am struggling with this a bit. I have SAS 9.2 and need to the following&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;) Run some SAS code - lets say hello.sas &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;2) Run matlab .m file &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;3) Run SAS code again &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I would like to put these steps in a *.BAT file &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;My hello.sas calls additional macros looks like the following &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;%macro initialize;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; %let path = C:\temp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;include "&amp;amp;path\MyTools.sas"; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;%MyTools(&amp;amp;path);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; %mend; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;%initialize; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;%run_my_test;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The MyTools macro incldues all macros used by the program.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;not sure how i can do this at least to get the first simple test rolling&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; "C:\Program Files\SAS\...\sas.exe" -sysin "C:\temp\hello.sas" all it does it opens sas and not do anything else Thanks for your help!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 24 Jun 2014 14:51:38 GMT</pubDate>
    <dc:creator>hdg</dc:creator>
    <dc:date>2014-06-24T14:51:38Z</dc:date>
    <item>
      <title>running batch file from windows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/running-batch-file-from-windows/m-p/154383#M40557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am struggling with this a bit. I have SAS 9.2 and need to the following&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;) Run some SAS code - lets say hello.sas &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;2) Run matlab .m file &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;3) Run SAS code again &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I would like to put these steps in a *.BAT file &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;My hello.sas calls additional macros looks like the following &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;%macro initialize;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; %let path = C:\temp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;include "&amp;amp;path\MyTools.sas"; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;%MyTools(&amp;amp;path);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; %mend; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;%initialize; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;%run_my_test;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The MyTools macro incldues all macros used by the program.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;not sure how i can do this at least to get the first simple test rolling&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; "C:\Program Files\SAS\...\sas.exe" -sysin "C:\temp\hello.sas" all it does it opens sas and not do anything else Thanks for your help!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jun 2014 14:51:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/running-batch-file-from-windows/m-p/154383#M40557</guid>
      <dc:creator>hdg</dc:creator>
      <dc:date>2014-06-24T14:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: running batch file from windows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/running-batch-file-from-windows/m-p/154384#M40558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What does it say in your log?&amp;nbsp; All I can see that your SAS program does is to include some other code, then call %run_my_test; whatever that does?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jun 2014 15:11:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/running-batch-file-from-windows/m-p/154384#M40558</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-06-24T15:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: running batch file from windows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/running-batch-file-from-windows/m-p/154385#M40559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;WARNING: Apparent invocation of macro MyTools not&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; resolved. %run_my_test is my main macro that does the analysis and produces reports&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jun 2014 15:17:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/running-batch-file-from-windows/m-p/154385#M40559</guid>
      <dc:creator>hdg</dc:creator>
      <dc:date>2014-06-24T15:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: running batch file from windows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/running-batch-file-from-windows/m-p/154386#M40560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Partially you may need %include. Without the % you should get an error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And a warning that your macros weren't found as the code in the %include file never executed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jun 2014 16:05:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/running-batch-file-from-windows/m-p/154386#M40560</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-06-24T16:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: running batch file from windows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/running-batch-file-from-windows/m-p/154387#M40561</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear HDG,&lt;/P&gt;&lt;P&gt;When running a batch SAS job from my Windows PC, I learned that you have to 1. open a batch executed SAS session; 2. Bring in the code that has any macros and execute the macros so that they are defined (compiled) in the batch session; and 3 run the actual code.&amp;nbsp; Sometimes I had a batch job that opened a SAS session (.exe); that called a SAS program (.sas) that defined the libraries (filename and libname statements) and 'included' the macro code (.sas) and finally 'included' the processing code.&amp;nbsp; In every situation, I had to define my libraries and macros before I could execute any other code.&amp;nbsp; I am looking for code examples and will send them when I find them.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: James Willis&#xD;
&#xD;
HDG,&#xD;
I used a .cmd file to start a SAS session that executed my REFRESH tables SAS routine.&amp;nbsp; Inside the tables.sas file were library statements and include statements.&amp;nbsp; The library definitions and macro definitions were always included before I included the code that actually executed the refresh code. &#xD;
&#xD;
@echo on&#xD;
rem&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; 'be certain of where the batch file is looking.&#xD;
&#xD;
START/W C:\"Program Files"\SAS\"SAS 9.1"\sas.exe -sysin "....path....\REFRESH SIM-Cmed tables.sas" &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jun 2014 16:09:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/running-batch-file-from-windows/m-p/154387#M40561</guid>
      <dc:creator>jwillis</dc:creator>
      <dc:date>2014-06-24T16:09:45Z</dc:date>
    </item>
    <item>
      <title>Re: running batch file from windows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/running-batch-file-from-windows/m-p/154388#M40562</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks that very helpful jwillis!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have got it to work it was really dumb mistake of not having the macro definitions being included correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do have another question if say my macro&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;test.sas looks like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro Initialize;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro getdata;&lt;/P&gt;&lt;P&gt;%Initialize;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro domything;&lt;/P&gt;&lt;P&gt;%Initialize;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How&amp;nbsp; do i invoke these macros separately in my bat file&lt;/P&gt;&lt;P&gt;"C:\Program Files\SAS\SASFoundation\9.2(32-bit)\sas.exe" -sysin&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;"First invoke getdata&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;"&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;"C:\Program Files\SAS\SASFoundation\9.2(32-bit)\sas.exe" -sysin&amp;nbsp; &lt;STRONG&gt; "Then do mything&lt;SPAN style="font-size: 10pt;"&gt;"&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jun 2014 19:13:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/running-batch-file-from-windows/m-p/154388#M40562</guid>
      <dc:creator>hdg</dc:creator>
      <dc:date>2014-06-24T19:13:50Z</dc:date>
    </item>
    <item>
      <title>Re: running batch file from windows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/running-batch-file-from-windows/m-p/154389#M40563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks ballardw thats exactly what it was&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jun 2014 19:14:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/running-batch-file-from-windows/m-p/154389#M40563</guid>
      <dc:creator>hdg</dc:creator>
      <dc:date>2014-06-24T19:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: running batch file from windows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/running-batch-file-from-windows/m-p/154390#M40564</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HDG,&lt;/P&gt;&lt;P&gt;I last ran .cmd files in 2004 so I am rusty.&amp;nbsp; There are several different ways to do what you need. I'll work on this tonight and tomorrow and see if I can find what I want to show you.&amp;nbsp; You cannot actually "call" a macro from a .cmd or .bat file.&amp;nbsp; Every time you&amp;nbsp; start a SAS session, you wipe out any macros previously defined in a session **.&amp;nbsp; When you invoke "getdata", you are not executing a macro, you are executing a SAS program (*.sas).&amp;nbsp; You have to initialize your libraries and macros (include a sas file with all the initializations) every time you execute sas.exe. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;** unless you compile them to a permanent library.&amp;nbsp; I do not have the skillset of using permanent compiled macros.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;stored in initialize.sas.&lt;/P&gt;&lt;P&gt;%macro Initialize;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%initialize;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;stored in getdata.sas.&lt;/P&gt;&lt;P&gt;%macro getdata;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%getdata;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;stored in domything.sas.&lt;/P&gt;&lt;P&gt;%macro domything;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%getdata;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;stored in callgetdata.sas;&lt;/P&gt;&lt;P&gt;%include Initialize.sas;&lt;/P&gt;&lt;P&gt;%include getdata.sas;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;stored in calldomything.sas;&lt;/P&gt;&lt;P&gt;%include Initialize.sas;&lt;/P&gt;&lt;P&gt;%include calldomything.sas;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How&amp;nbsp; do i invoke these macros separately in my bat file&lt;/P&gt;&lt;P&gt;"C:\Program Files\SAS\SASFoundation\9.2(32-bit)\sas.exe" -sysin&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;"First invoke getdata&lt;SPAN style="font-size: 10pt;"&gt;"&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;"C:\Program Files\SAS\SASFoundation\9.2(32-bit)\sas.exe" -sysin&amp;nbsp; &lt;STRONG&gt;"Then do mything&lt;SPAN style="font-size: 10pt;"&gt;"&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jun 2014 20:12:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/running-batch-file-from-windows/m-p/154390#M40564</guid>
      <dc:creator>jwillis</dc:creator>
      <dc:date>2014-06-24T20:12:48Z</dc:date>
    </item>
  </channel>
</rss>

