Getting Started with SAS in UNIX Environments |
How to Interrupt a SAS Process |
If you are using the current query to create a new data set, then the data set is still created even if the query is terminated. If you are using the current query to overwrite a data set, the data set is not overwritten if the query is terminated. In most cases you do not receive a warning that the query did not complete.
The method that you use to interrupt a SAS process depends on how you invoke SAS.
If you are running SAS in interactive line mode or in batch mode using a foreground process, then you can use either of the following methods to interrupt SAS:
Press the control key sequence that is set to interrupt in the shell that invoked SAS. In most cases, this control key sequence is CTRL+C. See the man page for the stty command to determine the appropriate key sequence for your environment.
Use the -SIGINT option in the kill command. For more information, see Using the UNIX kill Command.
If you are running the SAS windowing environment in the foreground, then click Interrupt in the SAS Session Manager window.
Note: You can access the SAS Session Manager by invoking SAS with the -dms or -dmsexp option. Select SAS: Session Management from the menu.
If you are running SAS in batch mode, then you must click Interrupt in the SAS Session Manager window. You cannot use a control key sequence to interrupt the SAS process.
The interrupt signal is sent to the host supervisor. The supervisor determines which DATA steps or procedures are running, and gives you options to interrupt these DATA steps or procedures. The actions that you can take appear in the interrupt menu. After you select an action, the host supervisor performs the operation you selected. Because the options in the interrupt menu are dependent on what is currently executing, you might see a different interrupt menu for the following:
each SAS procedure. The only option that procedures can act on is the Halt Datastep/Proc option.
a DATA step. The options available when SAS is processing a DATA step are different from when SAS is processing a procedure.
each SAS application. For example, SAS webAF has a different interrupt menu than the one for PROC SQL.
Note: Depending on the relational database, the interrupt signal might be handled differently. The interrupt signal is not handled until a safe point in the code is reached that allows the interrupt handler to be run safely.
The following is an example of the interrupt menu that you might see if you issue an interrupt signal while SAS is processing a PROC SQL statement:
Select: 1. Cancel Submitted Statements 2. Halt Datastep/Proc: SQL C. Cancel the dialog T. Terminate the SAS System
The following table explains each of these options:
Option | Description | What This Option Does |
---|---|---|
1 | Cancel Submitted Statements | Selecting this option will end the current DATA step or procedure and the underlying DBMS process. Outstanding source code that is waiting to execute will be flushed from the system. In interactive mode, you will return to the command prompt. |
2 | Halt Datastep/Proc: SQL |
If you select this option and SAS is currently executing
an SQL procedure, then the following menu appears:
Press: C to continue Q to cancel the current query S to cancel the submitted statements X to exit SQL procedure ?
|
C | Cancel the dialog | Selecting this option returns you to normal processing; however, the current query might have been interrupted. If you are running a long query and the control is on the DBMS server, then selecting C will end the current query. If you are running a short query and SAS has the control, then selecting C will cause the interrupt menu to disappear and the current query will continue. To determine whether the query was interrupted while reading or writing out the DBMS data, use PROC PRINT to view the partially created DBMS table or SAS data set. |
T | Terminate SAS | Selecting this option ends your SAS session as well as the current query. |
How to Terminate a SAS Process |
The method that you use to terminate a SAS process depends on how you invoke SAS.
If you are running the SAS windowing environment in the foreground, then click Terminate in the SAS Session Manager window.
If you are running an interactive SAS process in the background, then you must click Terminate in the SAS Session Manager window. You cannot use a control key sequence to terminate the SAS process.
If you click Terminate in the SAS Session Manager, then a dialog box appears confirming that you want to end the session. If you click OK, then both the SAS session and the current query are terminated. If you click Cancel, then you are returned to the SAS session.
What Happens When You Interrupt a SAS Process and the Underlying DBMS Process |
Interrupting your SAS and DBMS processes should be an exception. Extensive care should be taken when you construct your queries.
If SAS sends SQL to an RDBMS, there is no way to interrupt the SQL statements because SAS no longer has control of them. The statements are running in the RDBMS.
Note: In this section, SAS process refers to a series of events. It is not the process on the operating system. When you interrupt or terminate a SAS process, the process on the operating system might still be running.
When you interrupt or terminate a query on a server, the following processes stop:
processing of current extractions. For example, suppose you forgot to include a WHERE clause in your SQL query and are now extracting 1 billion rows into SAS. Issuing an interrupt stops the SAS process and the extract step in the DBMS.
processing of queries that are in progress on the server. For example, you have a very complex extract query that runs for a long time before producing a result. Issuing an interrupt stops the SAS and DBMS processes. As a result, the complex query running on your DBMS server is interrupted and terminated.
update, delete, and insert processing. For example, you are updating, deleting, or inserting many rows in your DBMS. An interrupt stops the SAS and DBMS processes.
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.