DATA Step, Macro, Functions and more

How to stop a long SAS code in the middle?

Reply
Regular Contributor
Posts: 205

How to stop a long SAS code in the middle?

Hello everyone,

 

I have a 1000 rows of SAS code they are around 30 data steps. if I want the SAS code stop executing  only after first 10 data steps  finish running. how to do that? I don't want to use 'endsas' command.

 

Thanks!

Super User
Posts: 5,082

Re: How to stop a long SAS code in the middle?

One common method is to define the steps that you don't want to run as being a macro.  For example, after the 10 steps that you want to run, insert this line of code:

 

%macro SkipThis;

 

Then at the end of the program insert this line:

 

%mend SkipThis;

 

That will define the 20 steps that you want to skip as the contents of a macro, but the program never executes the macro so the steps never run.

Super User
Posts: 3,106

Re: How to stop a long SAS code in the middle?

Another way is to select the steps you want to run using your mouse and press F3 / F8 to run the selection.

Super User
Posts: 5,256

Re: How to stop a long SAS code in the middle?

Why do you have code that you don't want to execute?
Are you executing interactively?
Consider splitting your program.
If you are an EG user there are means to group steps into different units, like a process flow.
Data never sleeps
SAS Employee
Posts: 51

Re: How to stop a long SAS code in the middle?

If you use the SAS Windowing environment, you can use this command:

 

subtop 19 

 

(it will submit the top 19 lines of code)

 

Koen

Super User
Posts: 10,500

Re: How to stop a long SAS code in the middle?

Yet another way COMMENTs and %include.

Put the code that you don't want to run into a separate program file. Then put an %include statement within comments so that it doesn't run.

 

<code>

/* comment not to run this

 

%include "path/myothercode.sas";

 

end comment */

 

When you want to run the code in the %include the Highlight that line and submit it. But if the whole program file is run the bit in the %include won't run.

 

 

Ask a Question
Discussion stats
  • 5 replies
  • 340 views
  • 1 like
  • 6 in conversation