TSO Statement: z/OS

Issues a TSO command or invokes a CLIST or a REXX exec during a SAS session.
Valid in: Anywhere
z/OS specifics: All

Syntax

TSO <command > ;

Optional 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, "system command" includes TSO commands, CLISTs, and REXX execs.

Details

Overview of the TSO Statement

The TSO statement is similar to the TSO (or SYSTEM) CALL routines, the TSO (or X) command, the TSO (or SYSTEM) function, and the %TSO (or %SYSEXEC) macro statement. SAS executes the TSO statement immediately. Under z/OS, TSO is an alias for the X statement. On other operating environments, the TSO statement has no effect, whereas the X statement is always processed.
Note: If any of these TSO statements are issued in a background environment, the command is not issued and the return code is set to 0.
You can use the TSO statement to issue most TSO commands or to execute CLISTs or REXX execs. However, you cannot issue the TSO commands LOGON and LOGOFF, and you cannot execute CLISTs that include the TSO ATTN statement. Nor can you issue authorized commands, such as some RACF commands. However, you can use the TSOEXEC command to issue authorized commands, as in this example: TSO TSOEXEC ALTDSD ...; In addition, you can use the TSO statement to issue the following UNIX System Services shell commands: cd, pwd, and umask. The shell command names must be specified in lowercase.

TSOEXEC

TSOEXEC is a TSO command that you use to invoke authorized commands. At z/OS sites that run under later releases of TSO/E, you can invoke authorized commands such as RACF commands by submitting the following statement:
tso tsoexec authorized-command;
For more information, see the IBM document TSO Extensions Command Reference.

Entering TSO Submode

You can also use the TSO statement to enter TSO submode during a SAS session.
To start the submode, place the TSO statement in your program without specifying any options. (In the windowing environment, enter TSO submode by issuing TSO as a command-line command. For more information, see TSO Command.) When the statement is executed, SAS enters TSO submode and prompts you for TSO commands. Any commands that you issue in TSO submode are processed by TSO; they are not processed as SAS statements. They can be any length. However, if the command is longer than one line, you must enter a TSO continuation symbol.
To return to the SAS session, issue RETURN, END, or EXIT. Any characters that follow the RETURN, END, or EXIT subcommand are ignored. An END command that occurs within a CLIST terminates the command procedure without ending the TSO submode.

Example

The following example SAS Macro enables you to determine whether the current SAS execution environment is TSO. If the environment is TSO, it invokes the TSO statement. If the environment is not TSO, it sets SYSRC to 12.
%macro TSOONLY(mycmd);
%if "&sysscp" = "OS" and "&sysenv" = "FORE" %then %do;
%sysexec &mycmd
%end;
%else %do;
%let sysrc=12;
%end;
%mend;
%let mycmd=lista sta sys hist;
%TSOONLY(&mycmd);
%put &sysrc;