Interrupting or Terminating Your SAS Session in UNIX Environments

Preferred Methods of Exiting SAS

The preferred methods of exiting a SAS session are the following:

  • select
    File Exit
    if you are using SAS in the windowing environment

  • use endsas ;

  • enter BYE in the command line

  • use CTRL+D if you are using SAS in interactive line mode.

Additional Methods for Interrupting or Terminating SAS

In addition to the preferred methods, you can terminate SAS in the following ways:

  • Press the interrupt or quit control key

  • Use the session manager

  • Enter the UNIX kill command.

Although you can terminate SAS using these techniques, you should try one of the four preferred techniques listed first.

Using Control Keys

Control keys enable you to interrupt or terminate your session by simply pressing the interrupt or quit key sequence. However, control keys can be used only when your SAS program is running in interactive line mode or in batch mode in the foreground. You cannot use control keys to stop a background job.


You cannot use control keys to stop a batch job that has been submitted with the batch , at , nohup ,or cron command.

Because control keys vary from system to system, issue the UNIX stty command to determine which key sends which signal. The stty command varies considerably among UNIX operating environments, so check the stty UNIX man page before using it. Usually, one of these forms of the command will print all of the current terminal settings:

 stty   stty -a   stty everything 

The output should contain lines similar to these:

 intr = ^C; quit = ^\; erase = ^H;   kill = ^U; eof = ^D; eol = ^@ 

The caret (^) stands for the CTRL key. In this example, CTRL+C is the interrupt key and CTRL+\ is the quit key.

Using the SAS Session Manager

If you invoke SAS in the windowing environment, you can use the session manager to interrupt or terminate your SAS session. The session manager is automatically iconified when you start SAS. To interrupt or terminate your SAS session, open the SAS Session Manager window and click Interrupt or Terminate .


Clicking Interrupt is equivalent to specifying the -SIGINT option on the kill command. Clicking Terminate is equivalent to specifying the -SIGTERM option on the kill command.

Using the UNIX Kill Command


Only use the kill command after you have tried all other methods to exit your SAS session.

The kill command sends an interrupt or quit signal to SAS, depending on which signal you specify. You can use the kill command to interrupt or terminate a SAS session running in any mode. The kill command cannot be issued from within a SAS session. You must issue it from another terminal or from another window (if your terminal permits it).

The format of the kill command is

kill <- signal- name > pid

To send the interrupt signal, specify -SIGINT . To send the terminate signal, specify -SIGTERM . Use the ps command to determine the process identification number ( pid )of the SAS session that you want to interrupt or terminate.

For example, suppose you want to stop a SAS job running in the background. First, issue the ps command to determine the PID of the SAS job.

 >ps      PID TTY      TIME COMMAND     2103 ttyu0    0:00 motifxsa     2111 ttyu0    0:01 sas     2116 ttyu0    0:00 ps     3856 ttyu2    0:03 ksh 

Four PIDs appear, but only one is for a SAS program. ( motifxsa is the SAS session manager. See "The SAS Session Manager (motifxsassm) in UNIX" on page 33 for more information.) Therefore, to send the interrupt signal to that SAS program, you would issue this command:

 kill -SIGINT 2111 

SAS replies with a prompt:

 Press Y to cancel submitted statements,   N to continue. 

For more information, refer to the UNIX man pages for the ps and kill commands.

Messages in the SAS Console Log

If SAS encounters an error or warning condition when the SAS log is not available, then any messages that SAS issues are written to the SAS console log. Normally, the SAS log is unavailable only early in SAS initialization and late in SAS termination.

Under UNIX, the STDOUT fileref specifies the location of the console log.

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 © 2008-2017.
If you may any questions please contact us: