DATA Step, Macro, Functions and more

ERRORABEND vs ENDSAS vs ABORT

Accepted Solution Solved
Reply
Contributor
Posts: 22
Accepted Solution

ERRORABEND vs ENDSAS vs ABORT

Hi,

 

Couldn't find the difference between ERRORABEND , ENDSAS ,ABORT.

 

What i understand is ,all terminate the SAS session if encounter error. But what is the difference and when to use which statement.

 

Thanks 


Accepted Solutions
Solution
‎02-21-2016 06:30 AM
Super User
Posts: 6,936

Re: ERRORABEND vs ENDSAS vs ABORT

ERRORABEND is a SAS System option, causing the system to immediately exit when an error is encountered (default is to continue with obs=0)

ENDSAS and ABEND are statements; ENDSAS simply terminates the SAS job or session gracefully, while ABORT also gives you control over the exit code handed back to the operating system.

ABORT terminates the current step, sets obs=0 and lets the SAS session/job continue (default behaviour for ERRORs)

ABORT ABEND terminates the step and terminates the SAS session/job immediately.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Super User
Posts: 5,256

Re: ERRORABEND vs ENDSAS vs ABORT

From top of my head:

Errorabend ends the SAS session when an error occurs. Use when you wish to make sure that nothing else will be executed.

Endsas ends the SAS session in a nice peaceful way, at your command.

Abort also ends the session but gives you some options to leave a RC back the calling program, like a UNIX she'll, scheduler etc.
Data never sleeps
Solution
‎02-21-2016 06:30 AM
Super User
Posts: 6,936

Re: ERRORABEND vs ENDSAS vs ABORT

ERRORABEND is a SAS System option, causing the system to immediately exit when an error is encountered (default is to continue with obs=0)

ENDSAS and ABEND are statements; ENDSAS simply terminates the SAS job or session gracefully, while ABORT also gives you control over the exit code handed back to the operating system.

ABORT terminates the current step, sets obs=0 and lets the SAS session/job continue (default behaviour for ERRORs)

ABORT ABEND terminates the step and terminates the SAS session/job immediately.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 391 views
  • 1 like
  • 3 in conversation