Date: Mon, 5 Apr 2010 11:07:37 -0500
Reply-To: "Data _null_;" <iebupdte@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Data _null_;" <iebupdte@GMAIL.COM>
Subject: Re: Running SAS batch programs asynchronously
Content-Type: text/plain; charset=ISO-8859-1
You may want to consider keeping it all in the family with the SAS
SYSTASK command. I twill allow you do start groups of programs that
run asynchronously WAIT for them to finish check the STATUS and start
other jobs asynchronously WAIT check STATUS ...
get the idea.
On 4/5/10, Scott Bass <email@example.com> wrote:
> This post is only tangentially related to SAS; still, I'm hoping someone
> here can give me some advice (perhaps Richard D. or Alan C.???)
> Environment: Windows XP, SAS 9.1.3 SP 4, using PC-SAS (DMS/batch),
> SAS/Connect, LSF is not licensed.
> Problem Statement/Design Criteria:
> * SAS programs will be run in batch
> * I want to run them asynchronously for better overall performance
> * However, there are dependencies between programs, so I need to wait for
> each "group" of programs to finish before starting the next "group".
> * I want to capture the return code (%ERRORLEVEL%) from each batch run
> * I'm currently approaching this using WSF and JScript, but am also willing
> to use VBScript.
> * Additional software install on end users machines is not an option, which
> rules out PowerShell, Perl, etc.
> For example, say I have programs "p1 - p9" in these groups:
> Group 1: p1 - p4
> Group 2: p5 - p6 (depends on datasets from p1 - p4
> Group 3: p7 - p9 (depends on datasets from p5 - p6
> My vision is generic scripts say "RunAsync.js" and "RunSAS.js" that would be
> called from a "wrapper" script like:
> RunAsync.js "RunSAS.js p1" "RunSAS.js p2" "RunSAS.js p3" "RunSAS.js p4"
> //group 1
> RunAsync.js "RunSAS.js p5" "RunSAS.js p6" //group 2
> RunAsync.js "RunSAS.js p7" "RunSAS.js p8" "RunSAS.js p9" //group 3
> RunAsynch.js would pause execution in the calling script until each program
> in the "group" ended. RunSAS.js will still capture %ERRORLEVEL% and echo
> success/fail messages to the console.
> If you have any Windows scripts that do something like this, please let me
> know. Alternatively, if you can at least suggest an approach to use, that
> would be great.
> P.S.: My current design thoughts are (but wide open to a better approach!):
> Launch each process named on the RunAsynch command line asynchronously,
> capture the process id, place the process id into an array, start a loop,
> sleep for a second or so, poll for the process id to no longer exist, save
> the exit code from the defunct process, delete the defunct process id from
> the array, and end the loop when the array length is zero.
> However, I'm not sure how to do this esp. in JScript / WMI / etc.