SYSTEM Function: z/OS

Issues an operating environment command during a SAS session and returns the system return code.
Category: Special
z/OS specifics: command, related commands, statements, macros
See: SYSTEM Function in SAS Functions and CALL Routines: Reference

Syntax

SYSTEM(command)

Required Argument

command
can be a system command enclosed in quotation marks, an expression whose value is a system command, or the name of a character variable whose value is a system command. Under z/OS, the term system command refers to TSO commands, CLISTs, and REXX execs.

Details

The SYSTEM function is similar to the X (or TSO) statement, the X (or TSO) command, the CALL SYSTEM (or CALL TSO) routine, and the %SYSEXEC (or %TSO) macro statement.
This function returns the operating environment return code after the command, CLIST, or REXX exec is executed.
SAS executes the SYSTEM function immediately. Under z/OS, TSO is an alias for the SYSTEM function. On other operating environments, the TSO function has no effect, whereas the SYSTEM function is always processed.
You can use the SYSTEM function to perform the following tasks:
  • issue most TSO commands.
  • execute CLISTs or REXX execs.
  • use the TSOEXEC command to issue authorized commands, such as the following example:
     system('TSOEXEC ALTDSD ...')
  • issue the following UNIX System Services shell commands: cd, pwd, and umask. The shell command names must be specified in lowercase.
You cannot use the SYSTEM function to perform the following tasks:
  • issue the TSO commands LOGON and LOGOFF.
  • execute CLISTs that include the TSO ATTN statement.
  • issue authorized commands, such as some RACF commands.

Example: Examples

In the following example, the SYSTEM function is used to allocate an external file:
data _null_;
   rc=system('alloc f(study) da(my.library)');
run;
For a fully qualified data set name, use the following statements:
data _null_;
   rc=system("alloc f(study) da('userid.my.library')");
run;
In the second example above, notice that the command is enclosed in double quotation marks. When the TSO command includes quotation marks, it is best to enclose the command in double quotation marks. If you choose to use single quotation marks, then double each single quotation mark within the TSO command:
data _null_;
   rc=system('alloc f(study)da(''userid.my.library'')');
run;