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
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;
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!
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.