I presume you are running SAS interactively, since you want SAS to stop processing code, but not close. That wouldn't make sense in a batch environment.
Try %abort cancel;
which is documented as
If the method of operation is windowing environment and interactive line mode, use the CANCEL option to do the following:
It only clears the current submitted program.
Other subsequent submitted programs are not affected.
The error message is written to the SAS log
So, in my windows sas session I submitted this code:
%macro test;
proc sql;
create table t as
select * from sashelp.class where sex='X';
quit;
%if &sqlobs=0 %then %abort cancel;
data t2;
set t;
run;
%mend test;
%test;
data t3; set t; run;
Because sashelp.class has no obs with sex='X' it made data set T with 0 observations, making &SQLOBS=0 and therefore executing the %abort cancel statement. The results were
Did not create data set T2
Did not create data set T3
The windows SAS session stayed open waiting for me to edit the program.
I got the same results running sas/studio.
... View more