<?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 Parrallel Processing in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Parrallel-Processing/m-p/699294#M213924</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this code should do the job:&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);
  do i=1 to N; drop i;
    file = dread(folderId, i);
    call symputX(cats("TEST_", i), file, "L");
    output; 
  end;

  rc = dclose(folderid);
  rc = filename(folderRef);

  call symputX("numberOfTests", N, "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 */
%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
;
%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\bart\Desktop\abc)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Test executed on the folder:&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;C:\Users\bart\Desktop\abc&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;which contains 3 files a.sas, b.sas, c.sas with the following code:&lt;/P&gt;
&lt;P&gt;a:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  rc = sleep(5,1);
  put "A";
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;b:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  rc = sleep(3,1);
  put "B";
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;c:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  rc = sleep(1,1);
  put "C";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;all the best&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
    <pubDate>Mon, 16 Nov 2020 20:11:51 GMT</pubDate>
    <dc:creator>yabwon</dc:creator>
    <dc:date>2020-11-16T20:11:51Z</dc:date>
    <item>
      <title>SAS Parrallel Processing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Parrallel-Processing/m-p/699219#M213885</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a folder with multiple SAS programs.&amp;nbsp;&amp;nbsp; I will like to run them all at one in parallel and not sequentially.&amp;nbsp; In the past, I have opened multiple SAS Sessions and open each program on a different SAS Session and run them.&amp;nbsp; This does the trick, but now I am having many more programs to run and I am looking for a simple code that I can have that will tell SAS to run the programs in that folder all at once in parallel sessions.&amp;nbsp; Hope someone can help me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Folder:&amp;nbsp; \\myserver\myfolder&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Programs:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;prg1.sas&lt;/P&gt;
&lt;P&gt;prg2.sas&lt;/P&gt;
&lt;P&gt;prg3.sas&lt;/P&gt;
&lt;P&gt;prg4.sas&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Nov 2020 16:46:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Parrallel-Processing/m-p/699219#M213885</guid>
      <dc:creator>ismahero2</dc:creator>
      <dc:date>2020-11-16T16:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Parrallel Processing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Parrallel-Processing/m-p/699282#M213921</link>
      <description>&lt;P&gt;If you are lucky enough to have SAS/CONNECT installed on your server then parallel processing is easy. See Example 5 in this link:&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=connref&amp;amp;docsetTarget=n11s7t6mbyae21n1byrkhyhofcqd.htm&amp;amp;locale=en"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=connref&amp;amp;docsetTarget=n11s7t6mbyae21n1byrkhyhofcqd.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Nov 2020 19:31:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Parrallel-Processing/m-p/699282#M213921</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-11-16T19:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Parrallel Processing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Parrallel-Processing/m-p/699294#M213924</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this code should do the job:&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);
  do i=1 to N; drop i;
    file = dread(folderId, i);
    call symputX(cats("TEST_", i), file, "L");
    output; 
  end;

  rc = dclose(folderid);
  rc = filename(folderRef);

  call symputX("numberOfTests", N, "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 */
%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
;
%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\bart\Desktop\abc)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Test executed on the folder:&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;C:\Users\bart\Desktop\abc&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;which contains 3 files a.sas, b.sas, c.sas with the following code:&lt;/P&gt;
&lt;P&gt;a:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  rc = sleep(5,1);
  put "A";
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;b:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  rc = sleep(3,1);
  put "B";
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;c:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  rc = sleep(1,1);
  put "C";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;all the best&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 16 Nov 2020 20:11:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Parrallel-Processing/m-p/699294#M213924</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-11-16T20:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Parrallel Processing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Parrallel-Processing/m-p/699295#M213925</link>
      <description>&lt;P&gt;If you use the systask it could be done with the BASE SAS only.&lt;/P&gt;
&lt;P&gt;All the best&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 16 Nov 2020 20:09:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Parrallel-Processing/m-p/699295#M213925</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-11-16T20:09:51Z</dc:date>
    </item>
  </channel>
</rss>

