BookmarkSubscribeRSS Feed
DDutton
Fluorite | Level 6

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

 

 

 

 

4 REPLIES 4
SASKiwi
PROC Star

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.

DDutton
Fluorite | Level 6

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.

  • batch mode and noninteractive mode
    • terminates the entire SAS program and SAS system.
    • writes an error message to the SAS log.
  • windowing environment and interactive line mode
    • clears only the current submitted program.
    • does not affect other subsequent submitted programs.
    • writes an error to the SAS log.
  • workspace server and stored process server
    • clears only the currently submitted program.
    • does not affect other subsequent submit calls.
    • writes an error message to the SAS log.
  • SAS IntrNet application server
    • creates a separate execution for each request and submits the request code. A CANCEL argument in the request code clears the current submitted code but does not terminate the execution or the SAS session.

 

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.  

 

So my real point is not about what could I do instead of use the DATA step with the ABORT statement, but about the fact that I believe this is a bug in SAS Studio and should have a defect opened against it and a Usage Note/Problem Note about it.  Before pursuing the opening of a defect, I thought I would check in with this forum to see if anyone else had run into this, and if they knew of a SASNote about it, as I could not find one.  What do y'all think?  Bug to be reported? I think so.
 
 
 
 
 
 
DDutton
Fluorite | Level 6

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.  

snow2021
Calcite | Level 5

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;  

 

 

 

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1775 views
  • 3 likes
  • 3 in conversation