BookmarkSubscribeRSS Feed
PedroBoareto
Calcite | Level 5

Hi,

 

I have a code with some macros where each of them extract a different data, and be like:

 

%extract_basex();

%extract_basey();

%extract_basez();

 

But, sometimes one of my macros get an error and the code stops. What could I do to for if one macro get an error the code goes to the next one?

 

For example, I want this:

%extract_basex(); --> Execute

%extract_basey(); --> Abend, the code stop this macro and goes to next

%extract_basez(); --> Execute

1 REPLY 1
Tom
Super User Tom
Super User

You can get more control by making your macro smart enough to detect the issues before they generate SAS errors and then skipping to the end of the macro.  Something like:

%macro extract_basex();
%let anyerr=0;
%if not exist(&input_ds) %then %do;
  %put ERROR: &=sysmacroname error. &=input_ds does not exist.;
  %let anyerr=1;
%end;
%if anyerr %then %goto quit;
/* code that uses &input_ds */
...
%quit:
/* Code that cleans up whether or not any errors */
%mend extract_basex;

 

 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 1 reply
  • 675 views
  • 2 likes
  • 2 in conversation