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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.