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
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).
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.
I have used the following
%abort cancel;
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With