BookmarkSubscribeRSS Feed
jacqelynl
Fluorite | Level 6

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.

 

Please help!

 

 

 

 

 

 

3 REPLIES 3
ChrisHemedinger
Community Manager

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.

 

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
jacqelynl
Fluorite | Level 6
Thank you for your quick response. I am not at my computer but will look at
all your suggestions and let you know

##- Please type your reply above this line. Simple formatting, no
attachments. -##
Kurt_Bremser
Super User

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".

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 776 views
  • 2 likes
  • 3 in conversation