DATA Step, Macro, Functions and more

macro code to conditionally abort a sas prg

Reply
Regular Contributor
Posts: 190

macro code to conditionally abort a sas prg

%macro bort(Condition);
%put Random debug print;
%if &Condition = stop_value %then %return;
%put After return;
%mend;

%bort(no_stop);
%put
%bort(stop_value);

 

hello here is my code %bort how do i make more flexible & generic to abort condionally a sas prg. can i use data_null_ plz give logic/code to enhamce my code. thanks in advance....

Super User
Posts: 3,260

Re: macro code to conditionally abort a sas prg

Do you know about the ERRORABEND option? That will abort a SAS program when an error is encountered.

 

You may also want to check out the ERRORCHECK and SYNTAXCHECK options and error handling in general:

 

http://support.sas.com/documentation/cdl/en/lrcon/68089/HTML/default/viewer.htm#n1nzmsupywf45qn1m6j1...

 

Regular Contributor
Posts: 190

Re: macro code to conditionally abort a sas prg

nope am not familiar with ERRORABEND concept.
Regular Contributor
Posts: 190

Re: macro code to conditionally abort a sas prg

i hav done a code to abort but how can i enhance it more to conditionally abort a sas prg can i add data_null_ & check condition or any other logic/code please do provide... thankU
Super User
Posts: 5,441

Re: macro code to conditionally abort a sas prg

It's funny that you ask if you can do something - didn't occured to you that you could test it yourself first?

 

Data never sleeps
Super User
Posts: 11,343

Re: macro code to conditionally abort a sas prg

You might want to check documentation for the %sysrc macro that returns values related to error conditons.

Also the system automatic macro variable SYSERR which is set at each step boundary (data step or procedure call)

 

 

Ask a Question
Discussion stats
  • 5 replies
  • 196 views
  • 0 likes
  • 4 in conversation