Friday, January 07, 2011

SAS programs from within a SAS program and suspend execution

You can launch SAS programs from within a SAS program and suspend execution of the launching SAS program until the launched SAS programs complete their execution. Doing this, you can control the execution sequence of your SAS programs if/when you do not want to depend entirely upon an OS's scheduling software (e.g. CRON on UNIX and Linux, Windows Scheduler on Windows, etc.).
For example, in your BIGPROGRAM.SAS, you could have the following code:
systask command "sas program1.sas" taskname=program1;

systask command "sas program2.sas" taskname=program2;

waitfor _all_ program1 program2;

/* Other SAS code that processes the data sets created by the two afore-mentioned programs */
Note that the _all_ option states that your program is to wait for both program1 _AND_ program2 to complete before resuming execution. As an alternative, you could have coded _any_, which would have your program resume the moment either program1 _OR_ program2 completed execution.

No comments:

Post a Comment

I love to hear from you! Leave a comment.
If your question is unrelated to this article, please use my Facebook page.