Introduction to SAS Interactive Line Mode
If you are not using an X display, you can invoke SAS in interactive line mode by using the NODMS system option.
You enter SAS statements line by line in response to prompts issued by SAS. SAS reads the source statements from the terminal as you enter them. DATA and PROC steps execute when one of the following occurs:
-
a RUN, QUIT, or DATALINES statement is entered
-
another DATA or PROC statement is entered
-
the ENDSAS statement is entered
To use interactive line mode, you must run SAS in the foreground.
Invoking SAS in Interactive Line Mode
To start an interactive line mode session, invoke SAS with the NODMS or NODMSEXP system option:
sas -nodms sas -nodmsexp
By default, SAS log and procedure output (if any) appear on your display as each step executes.
You can also invoke SAS in interactive line mode and pass parameters to it:
sas -sysparm 'A B C'
The value
A
B C
is assigned to the SYSPARM macro variable. You can include a program name, such as progparm.sas
in the Program Editor or from the SAS command prompt, if you invoked SAS in line mode by using the –nodms option.After you invoke SAS, the
1?
prompt appears, and you can begin entering SAS statements. After you enter each statement, a line number prompt appears.Exiting SAS in Interactive Line Mode
You can end the session by pressing the EOF key, usually Ctrl-D or by issuing the ENDSAS statement:
endsas;
The session ends after all SAS statements have executed.
Introduction to Running SAS in Batch Mode
To run SAS in batch mode, you specify your SAS program name in the SAS invocation command. You can run batch mode in the foreground, in the background by specifying an ampersand at the end of the SAS command, or submit your application to the batch queue by using the
batch
, at
, nohup
, or cron
UNIX commands. (For more information, see the UNIX man pages for the batch
, at
, nohup
, or cron
commands.) If you start your application with one of these UNIX commands and you log off from your system, then your application completes execution. If your application contains statements that start an interactive procedure such as FSEDIT, then you need to run your batch application in the foreground or you need to specify the –noterminal option.Invoking SAS in Batch Mode
To invoke SAS in batch mode, you must specify a filename in the SAS command. For example, if
weekly.sas
is the file that contains the SAS statements to be executed, and you want to specify the NODATE and LINESIZE system options, you would enter the following command:
sas weekly.sas -nodate -linesize 90
The command would run the program in the foreground. If you want to run the program in the background, add the ampersand to the end of the command:
sas weekly.sas -nodate -linesize 90 &
Submitting a Program to the Batch LSF Queue
To submit your program to the batch queue, you can use the
batch
, at
, nohup
, or cron
commands. For example, you could submit weekly.sas
from your shell prompt as follows:
$ bsub sas my_script.sas -nodms -nodate -linesize 90 $
Note: If your program contains statements that start an interactive procedure, such as the FSEDIT procedure, CATALOG procedure, or the REPORT procedure, you need to run your program as a foreground process, or use the –noterminal option.
Writing Data from an External File Using UNIX Pipes
You can use a UNIX pipe to write data from an external file to a SAS program. For example, suppose that your data resides in the external file
mydata
and your SAS program myprog.sas
includes this statement:
infile stdin;
Issue this command to run myprog.sas
, which reads data from the external file mydata
:
cat mydata | sas myprog.sas