DATA Step, Macro, Functions and more

Difference between stop and abort statement

Accepted Solution Solved
Reply
Regular Contributor
Posts: 234
Accepted Solution

Difference between stop and abort statement

This is from SAS doc.

 

The STOP statement stops processing of a DATA Step and passes control to the next statement following the end of the DATA step.

 

What does passes control mean here?

 

And under which conditions stop or abort statements are used?


Accepted Solutions
Solution
‎12-10-2015 11:10 AM
SAS Super FREQ
Posts: 3,483

Re: Difference between stop and abort statement

"Passes control" means that  SAS processes the next statement after the DATA step. This might be another DATA step, a procedure call, or a global variables. Often it is the statement after the RUN statement that ends the DATA step.

 

The ABORT statement is used when there is an unrecoverable error. For example, if a data set does not contain any valid observations for an analysis (maybe all are missing), you might want to exit the computation. The ABORT statement supports options that tell SAS what to do next (Continue on? Terminate SAS?).

 

The STOP statement is used to prevent an infinite loop when you are performing random access of observations. It does not imply that there was an error, it just means "stop the DATA step and continue processing the SAS program." The STOP statement must be used to end the DATA step processing when you use the POINT= option, because SAS never encounters the end-of-file indicator during random access. For an exaple, see the article "Sample with Replacement in SAS."

 

View solution in original post


All Replies
Trusted Advisor
Posts: 1,630

Re: Difference between stop and abort statement

"Passes control" means it executes the next statement after the data step.

 

ABORT can be used to stop a the execution of a datastep, or stop the execution of an entire program, or to end the entire SAS session.

Super User
Super User
Posts: 7,413

Re: Difference between stop and abort statement

TBH in 14 odd years I have never found a reason to use either and I suspect that the use of such suggest the program isn't written in a robust manner.  My log check pulls these terms out as errors.

Super User
Posts: 10,535

Re: Difference between stop and abort statement


RW9 wrote:

TBH in 14 odd years I have never found a reason to use either and I suspect that the use of such suggest the program isn't written in a robust manner.  My log check pulls these terms out as errors.


I suspect that most use of the abort is with mainframe batch jobs. I used to have a job that required running certain programs in batch that required human intervention, loading tapes to read and setting pens in a plotter. Because we were charged for computer time if the intervention wasn't performed in a timely manner or if the mounted tape didn't read correctly for any of a number of reasons we aborted the jobs with suitable messages written to the log. Admittedly that was nearly 30 years ago.

Solution
‎12-10-2015 11:10 AM
SAS Super FREQ
Posts: 3,483

Re: Difference between stop and abort statement

"Passes control" means that  SAS processes the next statement after the DATA step. This might be another DATA step, a procedure call, or a global variables. Often it is the statement after the RUN statement that ends the DATA step.

 

The ABORT statement is used when there is an unrecoverable error. For example, if a data set does not contain any valid observations for an analysis (maybe all are missing), you might want to exit the computation. The ABORT statement supports options that tell SAS what to do next (Continue on? Terminate SAS?).

 

The STOP statement is used to prevent an infinite loop when you are performing random access of observations. It does not imply that there was an error, it just means "stop the DATA step and continue processing the SAS program." The STOP statement must be used to end the DATA step processing when you use the POINT= option, because SAS never encounters the end-of-file indicator during random access. For an exaple, see the article "Sample with Replacement in SAS."

 

☑ This topic is solved.

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

Discussion stats
  • 4 replies
  • 502 views
  • 2 likes
  • 5 in conversation