11-24-2014 02:11 AM
I am trying to run write a script to mimic a scheduler. If some conditions meet, then I would like to run certain SAS files. I was playing around and I was able to write the code to run SAS files but this is not exactly what I am looking for. The SAS programs need to run simultaneously or in parallel.
%do i = 110 %to 151;
PROC SQL noprint;
SELECT PRG_SEQ , TRIM(RUN_DIR)||TRIM(PROGRAM_NME) AS PRG
INTO :ISINREADY, :ISPRG
%IF &ISINREADY =&I
There are about 30 programs. My objective is that if their status is 'READY', the program can run without manual intervention.
The problem with the above code is that the next program only runs when the SAS program in the include function has completed. Lot of these programs run for hours and totally independent from one another. I'd like them to run simultaneously.
I run this code in Unix. I did try X command but lot of the macros are defined elsewhere, hence giving macro not defined error. I looked for some suggestions, but my search did not result in any helpful topic.
I am sure there is a simple way to fix this. I would be very grateful, if anybody could help me.
Thank you very much.
11-24-2014 05:12 AM
I would not try to do the scheduling inside a SAS program, as this is clearly an operating system-level task.
The best option is to use some real scheduling system.
If you dont't have access to one in your company/organization, you could try to use cron and make in conjunction with a wrapper shell script for the sas programs.
The makefile would contain the conditions and actions based on semaphore files for the jobs, and the wrapper script would write the semaphores when completing a job successfully.
But the best option is to go for a real scheduling system.
11-24-2014 10:39 AM
Thank you very much Kurt. Eventually, I will have to play with the scheduler to schedule these jobs.
If the jobs were to run during a time period, then it would have been easy. The jobs need to run when the data is ready. This data is entered by the users manually.
I will have to find the macros used in these jobs, put them in a separate file and include them in the sas programs for the X command to run successfully. I will give that a shot.
11-24-2014 10:50 AM
There are scheduling systems that can run your job based on whether a file has been created, AutoSys comes to mind. Far superior than
trying to re-invent the wheel and build your own scheduler.