Using SAS 9.4 on our LINUX box and run daily CRON job which kicks off 150 SAS reports. I have to add a trigger to my CRON job so that the SAS reports will not kick off unless all these values are true in the Load_Status table. [If name = process_name and Status = Ready and date = today].
I can run a PROC SQL; to get the results but do not know how to put it into a macro do loop so that it repeats until the results resolve to true.
We have other triggers for other datasets which I understand because they are just looking for a dataset name which includes a date. This one needs to look for specific values inside a table.
If I understand you right, you want to schedule this job to run at a particular time (let's say 6:00 AM), but sometimes the dependencies won't be ready yet, and you don't want the SAS processing to happen until all data is in place. So...you want to poll the data (Load_Status) periodically until those conditions are true. You don't want to poll constantly over and over, but probably wait 1 or 2 minutes between checks, right?
You want to be careful not to create an infinite loop, so I'd advise adding another condition to check (like...it's LUNCHTIME) and give up for the day.
Check out this tip from @MMMIIIIKKKKEEEE about the WAKEUP function. That might be a useful way to tell your program to wait for a bit. SAS does have a lesser used (but still useful) control flow mechanism with GO TO and "label" constructs in a DATA step. You could use such a construct in DATA step to read the Load_Status table, if not ready then GO TO waitforit:, use WAKEUP to delay before checking again, etc.
Sorry it's not a complete solution. In the time I'm typing this someone else is probably composing something that is a perfect approach and ready to go....but at least I've plugged Mike's post.
P.S. Another approach might be to use a shell script in the cron job, let it run a SAS program to do the checking, write out an environment variable with the result, and include the looping/break logic in the shell script instead of in the SAS program.
Once you have reached this state of job complexity (150 reports is considerable), you should start building your own job infrastructure.
Since using a dedicated SAS server (and not just a SAS workstation), and the number of reports point to a certain size of your organisation, I think that there is an organisation-wide scheduling system already in place. I strongly recommend to attach the data warehouse to that.
For this I suggest:
1) have an individual program for your reports (or a group of reports created from the same source(s))
2) all those programs must be able to run in batch, with the same prerequisites (think Linux environment variables used for program control)
3) create a bash script that performs a single batch run, which handles the creation of individual job logs, and returns exit codes properly; you can find a blueprint for this in the Lev1/SASApp/BatchServer directory (you might even be able to customize this to your needs with the _usermods files)
Now you can start to build the connection from the organisation scheduler to the SAS box, and have your jobs run when the main scheduler has successfully run the jobs that create your inputs.
As an intermediate solution, you could also write a master script that repeatedly calls the script from 3) for all your jobs, checks for return codes, and handles the sequence as necessary.
While this means a lot of work to set up, once you have the infrastructure in place, adding new jobs and dependencies is a "piece of cake".
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.