BookmarkSubscribeRSS Feed
Loadbasic
Calcite | Level 5

We have production jobs that use SAS and is designed to fail whenever SAS returns an error.  Many of these production jobs read large amounts of data from external databases (Oracle, SQL server, etc.) via multiple queries, which will sometimes fail due to server issues.

 

I was wondering if there's a way to artificially catch these server errors and prevent SAS from throwing out an error itself; I wanted to make something similar to the .try/.catch system in other languages, where each DB query error would increment an internal counter and cause that query to restart; the job would abort after the internal counter reaches a certain threshold.  This is to prevent the jobs from breaking after a single timeout error on a single query after 2 hours of running other queries, requiring a restart of a long job.

 

Thanks.

2 REPLIES 2
Kurt_Bremser
Super User

There's two solutions:

  • the preferred one: spread your work over several successive jobs and let the scheduler keep track of success. No work is lost from the jobs 1 to n-1 if job n fails.
  • check within SAS for the &syscc automatic macro variable. It will be at zero as long as everything is OK.

The second method carries the risk that your SAS job is repeating a particular task even if that task CANNOT succeed at all, and thus wastes valuable time that could have been spent searching for and fixing the problem.

ballardw
Super User

@Loadbasic wrote:

We have production jobs that use SAS and is designed to fail whenever SAS returns an error.  Many of these production jobs read large amounts of data from external databases (Oracle, SQL server, etc.) via multiple queries, which will sometimes fail due to server issues.

 

 


Has your management team been apprised of how often these data sources fail? I would be very concerned if my databases are not accessible when actually needed.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1283 views
  • 0 likes
  • 3 in conversation