Ending a SAS Process on a Relational Database


How to Interrupt a SAS Process

Caution  

When you interrupt a SAS process, you might terminate the current query. 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 either case, however, 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.

      Note  

      This control key sequence will not interrupt a SAS process if you issue it in a SAS window, such as the Program Editor or SAS log.

    • Use the -SIGINT option in the kill command. For more information, see "Using the UNIX kill Command" on page 24

  • If you are running the SAS windowing environment in the foreground, then click Interrupt in the SAS Session Manager.

  • If you are running an interactive SAS process in the background, then you must click Interrupt in the SAS Session Manager. You cannot use a control key sequence to interrupt the SAS process.

The interrupt signal is sent to the DATA step or procedure that is currently executing for interpretation. The interrupt signal is interpreted differently by DATA steps and procedures. The actions that you can take appear in the interrupt menu. Since 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 options available for PROC SORT differ from those available for PROC SQL.

  • 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. If the DATA step or procedure does not respond to the interrupt in a given amount of time, then SAS does not terminate the current DATA step or procedure.

Example: Interrupt Menu for PROC SQL

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:

Table 1.2: Description of Interrupt Menu Options for PROC SQL

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. 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   ?  
  • If you select C , then the menu will disappear, but since the current query ended when you interrupted the SAS process, SAS will not return to the current query. Instead, SAS will begin processing the next line of code.

  • If you select Q , then SAS cancels the current query even if it is on a relational database. SAS continues processing the next statement.

  • If you select S , then all of the PROC SQL statements that you submitted are cancelled.

  • If you select X , SAS exits the current SQL procedure and starts processing the next statement in the submit block.

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 or not 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 the SAS System

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 in interactive line mode or in batch mode using a foreground process, use the -SIGTERM option in the kill command. For more information, see "Using the UNIX kill Command" on page 24:

  • If you are running the SAS windowing environment in the foreground, then click Terminate in the SAS Session Manager.

  • If you are running an interactive SAS process in the background, then you must click Terminate in the SAS Session Manager. 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

Caution  

Interrupting a SAS process and the underlying DBMS process might kill all jobs that are running on your DBMS. Interrupting your SAS and DBMS processes should be an exception. Extensive care should be taken when you construct your queries.

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.




SAS 9.1 Companion for UNIX Environments
SAS 9.1 Companion For Unix Enivronments
ISBN: 1590472101
EAN: 2147483647
Year: 2004
Pages: 185
Authors: SAS Institute

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net