- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
My program is divided so that there is a main program called 000_batch that running all other programs, look like:
%let pgm=C:\Users\freet\Desktop\SAS;
%include &pgm.010_batch;
%include &pgm.020_batch;
I want to give IF conditions in the program 010_batch that if the condition will met the SAS program will be stopped completely and not continue to 020_batch program.
I would appreciate your assistance
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It depends a bit on your version of SAS but assuming you're 9.4M5+ something like this works:
%if insertCondition %then %do;
%include .....;
%end;
%else %if insertCondition2 %then %do;
insert other code;
%end;
%else %do;
insert other code here;
%end;
@shlomiohana wrote:
Hello,
My program is divided so that there is a main program called 000_batch that running all other programs, look like:
%let pgm=C:\Users\freet\Desktop\SAS;
%include &pgm.010_batch;
%include &pgm.020_batch;
I want to give IF conditions in the program 010_batch that if the condition will met the SAS program will be stopped completely and not continue to 020_batch program.
I would appreciate your assistance
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Stopping a sas to run depends on what kind of condition is and what exactly you want to stop::
(1) In case the condition is based on input data then use:
If <condition> then stop run;
or if you want to cancel the batch job,or the sas sesssion you can use:
if <condition> then abort [abend] <return code>;
Better check the full documentation of ABORT statement.
(2) In case condition depends on outer arguments (suppose some macro variable or a return code from a sas step, then use @Reeza 's suggestion or code the macro program as:
%macro <macro_name>(...arguments ...);
%if <condition> %then ...
%else %if <condition to exit macro >
%then %goto exit;
.......
%exit:
%mend <macro_name>;