Previous Page | Next Page

SAS Macro Facility under Windows

Macro Statements

The following macro statement has behavior specific to Windows:


executes operating environment commands immediately and places the return code in the SYSRC automatic macro variable. The %SYSEXEC statement is similar to the X statement that is described in Running Windows or MS-DOS Commands from within SAS. You can use the %SYSEXEC statement inside a macro or in open code. The %SYSEXEC statement has the following syntax:

%SYSEXEC <command>;

The command argument can be any operating environment command or any sequence of macro operations that generates an operating environment command. You can also use the command argument to invoke a Windows application such as Notepad.

Omitting the command argument launches a command prompt subprocess, which is interactive. To return to your SAS session, type EXIT at the command prompt and press ENTER. The SYSRC automatic variable is set to 0 if you omit the command argument in the %SYSEXEC statement.

Here is a simple example of %SYSEXEC:

%sysexec time;

This statement launches a command prompt session that displays the following lines:

The current time is: 16:32:45.16
Enter new time:

Note:   The %SYSEXEC statement uses the XSYNC and XWAIT system option values just like the X statement and X command do. For more information about these system options, see XSYNC System Option: Windows and XWAIT System Option: Windows.  [cautionend]

Previous Page | Next Page | Top of Page