Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop SAS execution

Tags:

sas

Quick question

Is there a one-liner (or something rather short) method of cancelling the execution of further SAS statements from withing the windowing environement.

These are the methods I know of but they get tiresome, espeacially in huge programs with a lot of comments. I tried the ABORT and STOP statements but they close the windowing enviroment yet all I want is to stop execution at a certain point and go on my merry way.

Thanks

like image 902
Pane Avatar asked Aug 16 '13 19:08

Pane


People also ask

How do you stop a macro execution in SAS?

If you are using macros, you can exit a macro smoothly with %abort as long as you either use no options or only use cancel . Depending on what you're doing, you might set up your code to run in a macro (or macros) and use this option (although with the disadvantage of losing some log clarity).

What is STOP statement in SAS?

The STOP statement causes SAS to stop processing the current DATA step immediately and resume processing statements after the end of the current DATA step.


2 Answers

I have used the following

%abort cancel;
like image 20
Jeremy Bassett Avatar answered Nov 30 '22 11:11

Jeremy Bassett


This is something that comes up on SAS-L every so often. The answer is that it depends on what you're doing, largely.

The run cancel method is probably best if you are hoping to stop execution because of an error. At the top of your program you do:

%let cancel =; *or any macro variable name, but cancel is most logical;

Then in every run step you have:

data whatever;
... do stuff ...;
run &cancel;

And each time you have some potential error, you check the error condition and then if it hits,%let cancel=cancel; and you're good.

If you are using macros, you can exit a macro smoothly with %abort as long as you either use no options or only use cancel. Depending on what you're doing, you might set up your code to run in a macro (or macros) and use this option (although with the disadvantage of losing some log clarity).

Finally, if you're just interesting in being able to run a subset of your code, I recommend writing the code in multiple SAS programs for the bits you might want to run separately, then using %include from a master program to group them all together along with any macro variables you might want set that are shared. This is similar to how in EG you would construct many smaller programs and then group them using the process flow diagram.

like image 132
Joe Avatar answered Nov 30 '22 11:11

Joe