<?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: SAS batch run in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-batch-run/m-p/963538#M375363</link>
    <description>&lt;P&gt;1. &lt;U&gt;Just a note&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;If you have SAS/Connect, you have this functionality by using MP connect&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. &lt;U&gt;Please check&lt;/U&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;file names are like 'Test.sas' for log file or 'Test.sas' for lst type file.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It looks like you have file extensions hidden in Windows. Disable that nonsense.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 06 Apr 2025 02:02:25 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2025-04-06T02:02:25Z</dc:date>
    <item>
      <title>SAS batch run</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-batch-run/m-p/963537#M375362</link>
      <description>&lt;P&gt;I am using the following sas macro to batch run every sas program in the given location and create the log and lst files. However, I see the filenames were modifying little bit. is there any it can be fixed? Example: At given folder path I have a sas file 'Test'. When I ran the program it creating the lst and log files but file names are like 'Test.sas' for log file or 'Test.sas' for lst type file. Thank you in advance.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro runInParallel(filesLocation);

/* get the list of files */
data filesWithCodes;
  base = "&amp;amp;filesLocation.";
  length file $ 256 folderRef fileRef $ 8;

  folderRef = "_%sysfunc(datetime(), hex6.)0";

  rc=filename(folderRef, base);
  folderid=dopen(folderRef);

  N = dnum(folderId);
  j = 0;
  do i=1 to N; drop i;
    file = dread(folderId, i);
    if upcase(scan(file, -1, ".")) = "SAS" then
      do;
        j+1;
        call symputX(cats("TEST_", j), file, "L");
        output; 
      end;
  end;

  rc = dclose(folderid);
  rc = filename(folderRef);

  call symputX("numberOfTests", j, "L");
  stop;
run;
proc print data = filesWithCodes;
run;

/* setup sas sessions */
%local SASROOT SASEXE SASWORK;
filename sasroot "!SASROOT";
%let SASROOT=%sysfunc(PATHNAME(sasroot));
filename sasroot;
%put *&amp;amp;SASROOT.*;
%let SASEXE=&amp;amp;SASROOT./sas;
%put *&amp;amp;SASEXE.*;
%let SASWORK=%sysfunc(GETOPTION(work));
%put *&amp;amp;SASWORK.*;

%local t;   
systask kill 
  %do t = 1 %to &amp;amp;numberOfTests.;
    sas&amp;amp;t. 
  %end;
wait;

/* run parallel jobs */
/* you can adjust the config file location yourself by editing `-config ""&amp;amp;SASROOT./sasv9.cfg""` */
/* you can adjust outputs and logs locations yourself */
%do t = 1 %to &amp;amp;numberOfTests.;
%local sasstat&amp;amp;t.;
systask command
"""&amp;amp;SASEXE.""
  -sysin ""&amp;amp;filesLocation./&amp;amp;&amp;amp;TEST_&amp;amp;t.""
  -print ""&amp;amp;filesLocation./&amp;amp;&amp;amp;TEST_&amp;amp;t...lst""
    -log ""&amp;amp;filesLocation./&amp;amp;&amp;amp;TEST_&amp;amp;t...log""
 -config ""&amp;amp;SASROOT./sasv9.cfg""
   -work ""&amp;amp;SASWORK.""
 -noterminal
 -rsasuser"
taskname=sas&amp;amp;t.
status=sasstat&amp;amp;t.
NOWAIT /* change it to WAIT if you dont need to run it in parallel */
;
%end;

waitfor _all_
  %do t = 1 %to &amp;amp;numberOfTests.;
    sas&amp;amp;t. 
  %end;
;

data _null_;
  put "NOTE: The End!";
run;

%mend runInParallel;

options NOQUOTELENMAX;
%runInParallel(C:\Users\xx\Desktop\test)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 06 Apr 2025 01:40:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-batch-run/m-p/963537#M375362</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2025-04-06T01:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: SAS batch run</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-batch-run/m-p/963538#M375363</link>
      <description>&lt;P&gt;1. &lt;U&gt;Just a note&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;If you have SAS/Connect, you have this functionality by using MP connect&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. &lt;U&gt;Please check&lt;/U&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;file names are like 'Test.sas' for log file or 'Test.sas' for lst type file.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It looks like you have file extensions hidden in Windows. Disable that nonsense.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 06 Apr 2025 02:02:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-batch-run/m-p/963538#M375363</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2025-04-06T02:02:25Z</dc:date>
    </item>
    <item>
      <title>Re: SAS batch run</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-batch-run/m-p/963539#M375364</link>
      <description>&lt;P&gt;Since you are looking only for filenames that either end in .SAS (or files with no extension that are named just SAS) and then appending either .log or .lst to the names the the actual names of the THREE files will be:&lt;/P&gt;
&lt;PRE&gt;Test.sas
Test.sas.log
Test.sas.lst&lt;/PRE&gt;
&lt;P&gt;If you would rather that they be named:&lt;/P&gt;
&lt;PRE&gt;Test.log
Test.lst&lt;/PRE&gt;
&lt;P&gt;Instead then remove the last 4 characters from your macro variable with the filename.&lt;/P&gt;
&lt;P&gt;Either when you write them into the macro variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symputX(cats("TEST_", j), substr(file,1,length(file)-4), "L");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or when you use them to generate the SAS command.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS To make your first step no match filenames of SAS or sas then make sure the filename actually has a period in it before calling the SCAN() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if index(file,'.') and upcase(scan(file, -1, '.'))="SAS" then do;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 06 Apr 2025 04:17:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-batch-run/m-p/963539#M375364</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-04-06T04:17:39Z</dc:date>
    </item>
  </channel>
</rss>

