How to invoke/link a JCL step from SYSIN cards which contains SAS statements?

Reply
New Contributor
Posts: 2

How to invoke/link a JCL step from SYSIN cards which contains SAS statements?

I have to link and execute a JCL step from the SAS statements provided after SYSIN DD * . In SAS statements I have to check a condition which if satisfies, I need to go and execute a different JCL step in the same job. Can any one put a light on this?
I am unable to invoke a JCL step from SAS statements within SYSIN cards.

 

Snippet:

//EXIST1 EXEC SAS93

//SYSIN DD *

%macro check(dir= ) ;                     
%if %sysfunc(fileexist(&dir)) %then %do;  
%PUT 'FILE EXISTS'; 

>>>Here I need to invoke/link JCL Step STEP015 that is out of the scope of SYSIN Cards but present in same JOB<<
%end;                                     
%else %do ;                               
%PUT 'DOES NOT EXIST';                     
%end ;                                    
%mend ;                                   
                                          
%check(dir="ABC.DEF.GHI.JKL");

 

//STEP015 EXEC PGM=SYNCSORT

Super Contributor
Posts: 441

Re: How to invoke/link a JCL step from SYSIN cards which contains SAS statements?

I have an untested suggestion. First, there is afik no way to directly influence the execution flow of the JCL that started the SAS job. What can be done is have SAS end with a specific condition code if your condition is TRUE and have th enext step execute only if that condition is met.

 

SAS will set the condition code under control of the SYSCC macro var and/or the ABORT statement.

JCL will execute conditionally on that code using the COND= parameter on the EXEC card. For example:

 

//CNDSAMP JOB CLASS=6,NOTIFY=&SYSUID
//*
//STP01 EXEC SAS93
//* Assuming STP01 ends with RC0.

//STP02 EXEC PGM=SYNCSORT,COND=(0,EQ,STP01)
//* In STP02, condition evaluates to TRUE and step bypassed.

//STP03 EXEC PGM=IEBGENER,COND=((10,LT,STP01),(10,GT,STP02))
//* In STP03, first condition fails and hence STP03 executes. 
//* Since STP02 is bypassed, the condition (10,GT,STP02) in 
//* STP03 is not tested.

 

Hope this helps,

- Jan.

New Contributor
Posts: 2

Re: How to invoke/link a JCL step from SYSIN cards which contains SAS statements?

Posted in reply to jklaverstijn
Hi Jan,

Thanks for giving an idea how to accomplish this. But I have one more
concern that* I cannot afford to get a Return code not equals Zero*. If
that happens the code will give an abend in production. That is the reason
I want to check the condition in the step executing the sas
statements(which in either cases will give a MAXCC=00) and if the condition
doesn't satisfy I'll go to the very next step.

As shown in my code if I'm going to check the existence of the dataset in
JCL using LISTCAT I'm getting a Maxcc=00 for successful search but getting
Maxcc=04 for unsuccessful search which is causing abend to the code.

Is there any way around?

##- Please type your reply above this line. Simple formatting, no
attachments. -##
Super Contributor
Posts: 441

Re: How to invoke/link a JCL step from SYSIN cards which contains SAS statements?

Well than, short of an excursion towards USS and doing your thing in a shell script, I can only express my sympathy. If a warning (RC=4) raises an abend that catches the attention of your systems people they must be very busy folk and you have one hand tied to your back. I have nothing more to offer for the moment. I wish you all the best and look forward to learning how this is handled in the end.

 

Regards,

- Jan

Respected Advisor
Posts: 3,799

Re: How to invoke/link a JCL step from SYSIN cards which contains SAS statements?

You might consider calling SYNCSORT as a PROC.  You would need to put the SYNCSORT control cards into //SYSIN DD * which requires using a different SYSIN name for SAS (there's and option for that).

 

I used to use IEBUPDTE in that way.  It went something like this.

 

//SAS EXEC SAS93,OPTIONS=('SYSIN=SASIN")

//SYSIN DD *

iebupdte control cards

/*

//SASIN DD *

sas code

proc iebupdte;

   run;

more sas code

/*

//

 

I haven't done this is over 25 years and only assume it still works.

 

Another alternative would be to read the file into a SAS data set and sort it.

 

Maybe it would helpful to tell us the whole story.

Ask a Question
Discussion stats
  • 4 replies
  • 400 views
  • 1 like
  • 3 in conversation