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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 845 views
  • 0 likes
  • 2 in conversation