SYSTEM Function

Issues an operating environment command during a SAS session, and returns the system return code.

Category: Special
See: SYSTEM Function: z/OS in SAS Companion for z/OS



Required Argument


specifies any of the following: a system command that is enclosed in quotation marks (explicit character string), an expression whose value is a system command, or the name of a character variable whose value is a system command that is executed.

Operating Environment Information: See the SAS documentation for your operating environment for information about what you can specify. The system return code is dependent on your operating environment.
Restriction The length of the command cannot be greater than 1024 characters, including trailing blanks.


The SYSTEM function is similar to the X statement, 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, and accepts expressions as arguments. The X statement is a global statement and executes as a DATA step is being compiled, regardless of whether SAS encounters a conditional statement.


Execute the host command TIMEDATA if the macro variable SYSDAY is Friday.
data _null_;
   if "&sysday"="Friday" then do;
   else rc=system("errorck");

See Also

CALL Routines:
X Statement in SAS Statements: Reference