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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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