I want to execute a TSO command from my SAS job. I executed the following,
@DuraiN wrote:
Hi Tom,
I ran the code you suggested, it ended with RC 0 and I dont see any errors from SASLOG (provided below) but the file is not deleted,
1
2 DATA _NULL_;
3 RC=TSO("DEL 'RC.SAMPLE.SAS.UPGR'");
4 PUT RC=;
5 RUN;RC=0
NOTE: The DATA statement used 0.00 CPU seconds and 23366K
That seems consistent with the documentation text you posted before. You cannot run TSO commands from SAS launched via JCL, only from SAS launched via TSO command.
Your SAS code is missing a semi-colon to end the TSO statement. Also I doubt that you need either the DATA or the RUN statement to execute the TSO statement.
But I don't know if you can actually run TSO commands from JCL batch.
Hi Tom,
Thanks for your response! I was getting the following error (i.e. an exclamatory mark next to the semi-colon) earlier which is why I removed the semi-colon from the TSO statement,
1
2 DATA _NULL_;
3 TSO DEL 'RC.SAMPLE.SAS.UPGR'
3 ! ;
4 RUN;
I saw the following detail in SAS 9.4 Companion for z/OS, Third edition so wanted to check this feature of executing TSO commands from SAS,
TSO Function: z/OS
Issues an operating environment command during a SAS session and returns the system return code.
Restriction:
A TSO command executes successfully only in a TSO SAS session. In a non-TSO session, the command is disabled and the return code is set to 0.
z/OS specifics:
All
SyntaxTSO(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, "system command" includes TSO commands, CLISTs, and REXX execs.
It sounds like you cannot run TSO commands from batch jobs. But why not run the TSO() function instead of the TSO statement and see what return code you get?
DATA _NULL_;
RC= TSO("DEL 'RC.SAMPLE.SAS.UPGR'");
PUT RC=;
RUN:
Hi Tom,
I ran the code you suggested, it ended with RC 0 and I dont see any errors from SASLOG (provided below) but the file is not deleted,
@DuraiN wrote:
Hi Tom,
I ran the code you suggested, it ended with RC 0 and I dont see any errors from SASLOG (provided below) but the file is not deleted,
1
2 DATA _NULL_;
3 RC=TSO("DEL 'RC.SAMPLE.SAS.UPGR'");
4 PUT RC=;
5 RUN;RC=0
NOTE: The DATA statement used 0.00 CPU seconds and 23366K
That seems consistent with the documentation text you posted before. You cannot run TSO commands from SAS launched via JCL, only from SAS launched via TSO command.
Why not just use the FDELETE() function instead?
DATA TEST;
RC1=FILENAME('XXX', 'RC.SAMPLE.SAS.UPGR');
RC2=FDELETE('XXX');
PUT RC1= RC2=;
RUN;
To test TSO commands in SAS you need to launch SAS from a TSO command line using: TSO SAS (your launch script may have a different name). I'm assuming that TSO SAS is available to you though.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.