I'm trying to find a way to halt execution at a particular row. "Abort Abend" will do it, but it also seems to delete all my temprorary files. Is there a way to stop execution at particular row and keep the temporary files in the work directory?
In a DATA step, the STOP statement halts the current step. For example:
data want;
set have;
if amount > 5000 then stop;
run;
It stops before outputting the current observation. In this case, the output data set contains zero observations with amount greater than 5000.
Understood. However, unless I'm mistaken, the stop statement within a data step would only halt execution for that particular data step. Subsequent steps would proceed. I'd like the halt execution of the entire program, so no subsequent steps would run.
That takes a lot more work. For example, you could define a macro:
%macro runn;
%global halt;
run &halt;
%mend runn;
Then end every step by replacing the RUN; statement with:
%runn
Then in your DATA step:
if amount > 5000 then call symput('halt', 'cancel');
Before this point, the %RUNN macro would generate:
run;
Afterwards, it generates:
run cancel;
There's no easy way that I know of.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.