Hello all;
I run SAS on PC;
I want an alternative SAS code of 'ENDSAS' that will stop running the rest of SAS code without quit SAS session.
Please advise.
Thanks!
data a; x=1; run; endsas;/* need something here without quiting SAS session*/ *don't want data b; data b; x=3; run;
Look at the ABORT statement
ABORT CANCEL; seems to be what you want
but maybe one of the other options will work better for you.
thanks,
but :ERROR 180-322: Statement is not valid or it is used out of
proper order.
@GeorgeSAS wrote:
thanks,
but :ERROR 180-322: Statement is not valid or it is used out of
proper order.
Perhaps you could show us the relevant portion of the SASLOG so we might be able to figure out what went wrong.
data a; x=1; abort cancel; run;
But this is such a trivial example as to be meaningless.
Normally, you'd want to abort if some variable takes on a value that it shouldn't have, where you stop execution of the code if the variable has such a value, and you continue to execute the code when the variable takes on values that are allowed. There are examples in the documentation of using ABORT this way. Is that what you want?
data a; x=1; run; /* data b; x=3; run;
this works but is a comment like method.
DOUBLE checked, this not work!!!
after /* if there are some macros or other comments /**/... some of the program code will still be executed.
put in bold,this will alert me that will cause error and almost it can't be recognized .
@GeorgeSAS What are you trying to achieve here?
If something errors out, that the process stops or if you want the program to stop at a location, why have the rest of the code in the first place. I'm not understanding the business/process requirements here.
DATA A; X=1; RUN; %MACRO A; DATA B; X=2; RUN; %MEND;
In batch mode 'endsas' works well, but in PC interactive mode,I know we can use macro.
Thank you Reeza!
The reason I need this methods is I am working on developing stage,some code I don't want them to be run currently but will run them in the future.
That's an obvious gap in the SAS language, and an age-old request.
See this page to vote for such a statement (but don't hold your breath) and to find a link to a workaround.
I think in most case base-SAS run in different platforms at the same time ,try not to create a new statement will reduce the confuse of people.
write a little bit more code(macro) will solve the problem. safely and confidently not mess/screw up the program.
I'm confused. What was wrong with the original solution of abort cancel? In interactive SAS, I think it does just what you're looking for. AFAIK, it's the "best" way to stop a submission in interactive SAS, without ending the SAS session. It's even better than syntax check mode, since it prevents all code form being executed.
data a;
x=1;
run;
/* need something here without quitting SAS session*/
data _null_;
abort cancel;
run;
*don't want data b;
data b;
x=3;
run;
Returns:
1 data a; 2 x=1; 3 run; NOTE: The data set WORK.A has 1 observations and 1 variables. 4 5 /* need something here without quiting SAS session*/ 6 data _null_; 7 abort cancel; 8 run; ERROR: Execution terminated by an ABORT CANCEL statement at line 7 column 3. _ERROR_=1 _N_=1 NOTE: The SAS System stopped processing due to receiving a CANCEL request.
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.