| SAS Companion for the OS/2 Environment |
You can submit the X statement to exit your SAS session temporarily
and gain access to the OS/2 command processor. The X statement takes the form
The optional command argument is used either
to issue an operating environment command or to invoke an OS/2 application
such as the OS/2 System Editor. This discussion concentrates on using the
X statement to issue operating environment commands; note, however, that
the X statement can also be used to invoke OS/2 applications.
Note:
The X statement is similar to the X command.
The major difference between the two is that the X statement is submitted
like any SAS statement; however, the X command is issued as a windowing environment
command. This section uses the X statement in examples, but the information
applies to the X command as well.
If you want to issue only one operating environment
command, include the command as an argument in the X statement. When you
submit the X statement, the command is issued, and you cannot issue any additional
commands.
If you want to issue several operating environment commands,
submit the X statement without an argument. A command prompt appears where
you can enter an unlimited number of operating environment commands. Remember,
however, that the commands that you issue from the command prompt do not affect
the SAS process. For example, if you change from the SAS working directory
to MYDATA at the command prompt, the SAS System still uses the SAS directory
as its working directory. Also, any environment variables that you define
are not available to the SAS System. If you submit an X statement or command
without a command argument, type EXIT to return to your SAS session.
Other methods of temporarily exiting your SAS session
include
If you want to issue operating environment
commands conditionally, use the CALL SYSTEM routine, as in the following example:
options noxwait;
data _null_;
input flag $ name $8.;
if upcase(flag)='Y' then
do;
command='md c:\'||name;
call system(command);
end;
cards;
Y mydir
Y junk2
N mydir2
Y xyz
;
This example uses the value of the variable FLAG to
conditionally create directories. After the DATA step runs, three directories
have been created: C:\MYDIR, C:\JUNK2, and C:\XYZ. The directory C:\MYDIR2
is not created because the value of FLAG for that observation is not
Y.
The X command is a global SAS statement; therefore,
it is important to realize that you cannot conditionally issue the X command.
For example, if you submit the following code, the X statement is issued:
data _null_;
answer='n';
if upcase(answer)='y' then
do;
x 'md c:\extra';
end;
run;
In this case, the directory C:\EXTRA is created regardless
of whether the value of ANSWER is equal to
n or
y.
For more information about the CALL SYSTEM routine,
see CALL SYSTEM
and the section on functions and CALL routines in SAS Language Reference: Dictionary.
The XWAIT system option
controls whether you have to type EXIT
to return to your SAS session after an X statement or command has finished
executing a DOS command. (The XWAIT system option is not used if an X statement
is issued without a command argument or if the X statement invokes
an OS/2 application such as the EPM editor.) This option and its negative
form operate in the following ways:
If you issue an X statement or command without a command argument, you must type EXIT
to return to your SAS session, even if
NOXWAIT is in effect.
When a window that was created by an X statement is
active, reactivating the SAS System without exiting from the command processor
causes the SAS System to issue a message box containing the following message:
The X command is active. Enter EXIT at
the prompt in the X command window to
reactivate this SAS session.
If you receive this message box, type the EXIT command
from the command prompt to close the window and return to your SAS session.
The XSYNC option specifies whether the operating environment
command you submit runs synchronously or asynchronously with your SAS session.
This option and its negative form operate in the following ways:
Specifying NOXSYNC can be useful if you are starting
applications such as the EPM editor from your SAS session. For example, suppose
you submit the following X statement:
x epm;
If XSYNC is in effect, you cannot return to your SAS
session until you close EPM. But if NOXSYNC is in effect, you can switch
back and forth between your SAS session and the NOTEPAD. The NOXSYNC option
breaks any ties between your SAS session and the other application. You can
even end your SAS session. The other application stays open until you close
it.
The XWAIT and XSYNC options have very different effects. An
easy way to remember the differences is the following:
The various option combinations are summarized in
Combining the XWAIT and XSYNC System Options.
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.