10-17-2017 03:46 PM - edited 10-17-2017 03:53 PM
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.
data a; x=1; run; endsas;/* need something here without quiting SAS session*/ *don't want data b; data b; x=3; run;
10-17-2017 03:58 PM
but :ERROR 180-322: Statement is not valid or it is used out of
Perhaps you could show us the relevant portion of the SASLOG so we might be able to figure out what went wrong.
10-17-2017 04:04 PM
10-17-2017 04:09 PM - edited 10-17-2017 04:11 PM
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?
10-17-2017 03:54 PM - edited 10-17-2017 05:57 PM
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 .
10-17-2017 04:08 PM
@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.
10-17-2017 05:51 PM - edited 10-17-2017 05:54 PM
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.
10-18-2017 12:59 AM
10-18-2017 12:15 PM - edited 10-18-2017 12:16 PM
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.
10-19-2017 11:15 AM
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;
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.