Tip of the Day:January 4

From sasCommunity
Jump to: navigation, search

sasCommunity Tip of the Day

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 your_clever_program1.sas" taskname=program1;
 
systask command "sas your_clever_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.

Submitted by Michael A. Raithel, The man who wrote the book on performance. Contact me at my Discussion Page.



Feel free to comment on this tip.


Prior tip - Next tip - Random Tip

Submit a Tip