BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DuraiN
Calcite | Level 5

I want to execute a TSO command from my SAS job. I executed the following,

//STEP01   EXEC SAS
//SYSIN    DD   *
DATA TEST;
TSO DEL 'RC.SAMPLE.SAS.UPGR'
RUN;
/*
The job ended with RC 0 but I see the following (error?) in SASLOG,
1
2          DATA TEST;
3           TSO DEL 'RC.SAMPLE.SAS.UPGR'
4           RUN
4        !     ;
NOTE: The data set WORK.TEST has 1 observations and 0 variables.
NOTE: The DATA statement used 0.00 CPU seconds and 23258K.
 
Can someone please help me understand what is wrong with this code?
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

@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.  

View solution in original post

9 REPLIES 9
Tom
Super User Tom
Super User

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.

DuraiN
Calcite | Level 5

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.

Tom
Super User Tom
Super User

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:
DuraiN
Calcite | Level 5

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
Tom
Super User Tom
Super User

@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.  

Tom
Super User Tom
Super User

Why not just use the FDELETE() function instead?

DATA TEST;
  RC1=FILENAME('XXX', 'RC.SAMPLE.SAS.UPGR');
  RC2=FDELETE('XXX');
  PUT RC1= RC2=;
RUN;
DuraiN
Calcite | Level 5
Thanks for your suggestion Tom! but the idea behind testing the SAS-TSO interface was to test the features in current version of SAS and then do the test again after we upgrade the version. But may be I cannot run TSO commands from SAS..
SASKiwi
PROC Star

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.

DuraiN
Calcite | Level 5
Categorization: Unclassified

Thanks for your response! Yes we have a TSO SAS session available...will run it thru it


SAS Innovate 2025: Register Now

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!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 9 replies
  • 1269 views
  • 0 likes
  • 3 in conversation