BookmarkSubscribeRSS Feed
Batman
Quartz | Level 8

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?

3 REPLIES 3
Astounding
PROC Star

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.

Batman
Quartz | Level 8

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.

Astounding
PROC Star

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.

sas-innovate-2024.png

Today is the last day to save with the early bird rate! Register today for just $695 - $100 off the standard rate.

 

Plus, pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 810 views
  • 0 likes
  • 2 in conversation