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.
There's two solutions:
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.
@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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.