Desktop productivity for business analysts and programmers

Error Handling in SAS EG

Regular Learner
Posts: 1

Error Handling in SAS EG


I am working on SAS Enterprise 4.3

I have various programs on a project , my requirement is that as soon as there is an error in any of the program , then the sas processing is stopped and i need to capture the error and mail it to the user who is running the project.


I would also like to share my thoughts regarding solutions:

a) use options errorabend , but this disconnects the user from the server and log is also lost , for which i saved log at a particular location and was able to scan for error and error message but since user is disconnected  he/she will have to connect and run that code which is not feasible.


b) creating three macros:

1) if &syserr > 0 then %put : &syserrtxt

2) create a macro for mail-successful and unsucessful run as per syserr

3) abort program again as per &syserr


Issue with the above aproach is that my codes in individual programs are huge and will have to call this macro again and again in between the codes.



c) I am not sure if i can sue conditional processing , if yes then How?



Super User
Posts: 4,026

Re: Error Handling in SAS EG

The type of control you want over your SAS applications would be much better handled if you converted your EG project to run as a SAS batch job. ERRORABEND works with no problem in batch, logs are kept automatically and if you use the server-based schedulers available via SAS Management Console then emailing happens automatically too.


If your project is a business-critical process then you should seriously consider server-based scheduling and batch processing for your production jobs - in my view this would be best practice. PCs are just not reliable enough. Use EG for development and testing only.

Super User
Posts: 10,584

Re: Error Handling in SAS EG

Concur with @SASKiwi. Once you reach that level of process complexity, using a solid scheduler to run your programs in batch, and using the scheduler's capabilities to detect correct and incorrect batch runs, is a must.

Check which scheduling software is used in your organisation, and have your SAS server integrated there.

Everything else is just a form of slow and painful suicide.

Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation