%SYSEXEC Statement

Issues operating environment commands.
Type: Macro statement
Restriction: Allowed in macro definitions or open code
See: SYSSCP and SYSSCPL Automatic Macro Variables and SYSRC Automatic Macro Variable

Syntax

%SYSEXEC<command> ;

Required Arguments

no argument
puts you into operating environment mode under most operating environments, where you can issue operating environment commands and return to your SAS session.
command
is any operating environment command. If command contains a semicolon, use a macro quoting function.

Details

The %SYSEXEC statement causes the operating environment to immediately execute the command that you specify and assigns any return code from the operating environment to the automatic macro variable SYSRC. Use the %SYSEXEC statement and the automatic macro variables SYSSCP and SYSSCPL to write portable macros that run under multiple operating environments.
Operating Environment Information: The following items related to the use of the %SYSEXEC statement are operating environment specific. For details, see the SAS documentation for your operating environment.
  • the availability of the %SYSEXEC statement in batch processing, noninteractive mode, or interactive line mode.
  • the way you return from operating environment mode to your SAS session after executing the %SYSEXEC statement with no argument.
  • the commands to use with the %SYSEXEC statement.
  • the return codes that you get in the automatic macro variable SYSRC.

Comparisons

The %SYSEXEC statement is analogous to the X statement and the X windowing environment command. However, unlike the X statement and the X windowing environment command, host commands invoked with %SYSEXEC should not be enclosed in quotation marks.