X Statement
Issues an operating-environment command from within a SAS session.
| Valid in: | Anywhere |
| Category: | Operating Environment |
| Restriction: | This statement is not valid on the CAS server. |
Table of Contents
Syntax
Without Arguments
Using X without arguments
places you in your operating environment, where you can issue commands
that are specific to your environment.
Arguments
'operating-environment-command'
specifies an operating environment command that is enclosed in quotation marks.
Operating Environment Information: specifies
the Linux command. If
you specify only one Linux
command, you do not need to enclose it in quotation marks. Also, if
you are running SAS from the Korn shell, you cannot use aliases.
Details
General Information
In all operating environments,
you can use the X statement when you run SAS in windowing or interactive
line mode. In some operating environments, you can use the X statement
when you run SAS in batch or noninteractive mode. Keep in mind that
the way you return from operating environment mode to the SAS session
is dependent on your operating environment and the commands that
you use with the X statement are specific to your operating environment.
You can use the X statement
with SAS macros to write a SAS program that can run in multiple operating
environments. See the SAS Viya Macro Language: Reference for information.
Linux Specific Information
The X statement issues
a Linux command from
within a SAS session. SAS executes the X statement immediately.
Neither the X statement
nor the %SYSEXEC macro program statement is intended for use during
the execution of a DATA step. The CALL SYSTEM routine, however, can
be executed within a DATA step.
Note: The X statement is not supported
without arguments under the X Window System.
Comparisons
In a windowing session, the X command works exactly
like the X statement except that you issue the command from a command
line. You submit the X statement from the Program Editor window.
The X statement is similar
to the SYSTEM function, the X command, and the CALL SYSTEM routine.
In most cases, the X statement, X command or %SYSEXEC macro statement
are preferable because they require less overhead. However, the SYSTEM
function can be executed conditionally. The X statement is a global
statement and executes as a DATA step is being compiled.
See Also
Executing Operating System Commands from Your SAS Session in Batch and Line Mode Processing in SAS Viya
Copyright © SAS Institute Inc. All Rights Reserved.
Last updated: March 29, 2017