SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
Mayt
Quartz | Level 8

Hi everyone

I have a job flow that contains  jobs inside. Some jobs need to run in parallel. I used to execute it by right click--> execute and set time trigger, and the job flow worked fine. 

Mayt_0-1708605633123.png

The problem is right now I want to execute the job flow through API. But can't find any solution.

I've tried one solution like Instead of creating a job flow, I created job definition then put the each-step code in it and used %include to run the each-step code. Then executed it through API. But It can't run in parallel and didn't show if there are errors each step.

My code in job definition is something like this:

/*include file*/
FILENAME first_code FILESRVC FOLDERPATH='code path'  FILENAME='mycode1.sas';
FILENAME sec_code FILESRVC FOLDERPATH='code path'  FILENAME='mycode2.sas';
FILENAME third_code FILESRVC FOLDERPATH='code path'  FILENAME='mycode3.sas';

%include first_code;
%if &SYsrc=0 %then %do;
    %put Return Code for first_code: &SYSRC;
    %include sec_code;
    %if &SYsrc=0 %then %do;
        %put Return Code for sec_code: &SYSRC;
        %end;
     %include third_code;
        %if &SYsrc=0 %then %do;
        %put Return Code for third_code: &SYSRC;
        %end;
      

So if you guys know how to execute the job flow through API, please let me know.

Thank you in advanced.

3 REPLIES 3
ChrisHemedinger
Community Manager

Yes, SAS Viya has a Job Execution API. You can also list Jobs and get status of running Jobs.

 

See examples here:
https://github.com/sassoftware/devsascom-rest-api-samples/blob/master/Compute/jobExecution.md

 

And documentation:
https://developer.sas.com/apis/rest/Compute/#job-execution

 

This Postman collection might also help for testing:
https://github.com/sassoftware/sas-rest-api-postman-collections/tree/master/jobs-crud

 

Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!
Mayt
Quartz | Level 8

So I need to call the job flow in job definition, Then execute the job definition right? How can I call the job flow in job definition? Can I just use %include like I did in my code. But I think job flow doesn't have path.

DeMer
Obsidian | Level 7

Can you use the job chaining macros that are provided with the Job Execution Webapp?

https://go.documentation.sas.com/doc/en/sasstudiocdc/v_047/pgmsascdc/jobexecug/p0qsxn76pbh5qjn1iob6u...

 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1766 views
  • 1 like
  • 3 in conversation