I've searched the Problem Notes and the Conversations here in the SAS Studio community, but have not found a mention of the problem that I recently stumbled on. In macro code submitted via SAS Studio 3.6 running on Windows 2012 R2 servers, the following DATA step was conditionally executed:
data _null_;
abort cancel nolist;
run;
The ABORT statement was processed as one would expect, with the normal error message:
ERROR: Execution terminated by an ABORT CANCEL statement at line x column y.
The next time that a SUBMIT operation is performed, the following errors and warnings result.
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
ERROR: At least one file associated with fileref _HTMLOUT is still in use.
ERROR: Error in the FILENAME statement.
ERROR: At least one file associated with fileref _RTFOUT is still in use.
ERROR: Error in the FILENAME statement.
WARNING: SASDATE value cannot be changed in mid document.
The submitted code executes normally. And apparently, the actions that were not taken after the ABORT statement was executed are successfully executed now, because subsequent SUBMIT operations do not encounter these errors.
We are planning to recode our macro to avoid use of the ABORT statement, but it seems like there ought to be a Usage Note or Problem Note about this. If there is, my searches failed to find it.
Is this a known bug?
Thanks,
dd
The ABORT statement closes the SAS session your SAS Studio client has been using at that point so it probably bypasses some cleanup stuff that SAS Studio would normally do when closing a session. The next code submit would therefore need to trigger a brand-new SAS session where you would be starting from scratch and need to repeat any session setup stuff you need. I'm not surprised SAS Studio might have some difficulty "picking up the pieces".
I'm not sure why you would want to use ABORT in this context. This statement's main use would be for batch jobs where you simply want to halt any further execution of statements. Perhaps if you explained your use case we might be able to suggest alternatives.
Actually, the ABORT statement does NOT end the SAS Session when submitted within SAS Studio, or within SAS Enterprise Guide. That would certainly be a bug per the documentation:
ABORT statement CANCEL option doc:
CANCEL <FILE>
causes the execution of the submitted statements to be canceled. Actions depend on the method of operation.
Try submitting this code in SAS Studio and observing the data sets in the WORK llibrary.
%macro abort_test;
data ;
x=1;
run;
data _null_;
abort cancel nolist;
run;
%mend;
%abort_test;
You'll see that the data sets (DATA1, DATA2, etc.) created in each execution remain in the WORK library, showing that the SAS Session is not terminated.
However, in SAS Studio on code submitted after the submit with the ABORT statement, errors are generated regarding the filerefs and SASDATE value. In Enterprise Guide, no such errors are encountered. SAS Studio, like Enterprise Guide, should handle this statement gracefully, not issue error messages on the next SUBMIT operation.
As to the purpose of the submitted DATA step with the ABORT statement - it was conditionally executed by the macro to end the currently running program which calls this macro. Most of our programmers use either batch submit or SAS Enterprise Guide, so have not hit this problem.
In case any one is interested, Tech Support reports that this is a known bug fixed in SAS Studio 5.1, which runs on the SAS Viya Architecture.
Thanks for the info. I had the same issue to use %ABORT CANCEL statement as well. I recently got help from SAS instructor Allison Saito for a workaround solution which worked well - using below code can properly close the environment files and run other code again without '..file in use' error -
......
ODS HTML CLOSE;
ODS HTML5 (ID=WEB) CLOSE;
ODS RTF (ID=WEB) CLOSE;
ODS PDF (ID=WEB) CLOSE;
%ABORT CANCEL;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: