SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Launching SAS DI jobs using shell

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 10
Accepted Solution

Launching SAS DI jobs using shell

Hi

Can anybody help me with the commands needed to launch a DI Job (containing other DI jobs and an input file)?

It is on Linux and it has to be a shell script.

Thanks in advance

Kind regards

Andreas


Accepted Solutions
Solution
‎05-18-2015 03:29 AM
Super User
Posts: 5,429

Re: Launching SAS DI jobs using shell

Posted in reply to andreas_gryn

The shell script will return any SAS session RC. Whether it's easy or not capture this depends on how you will call/execute the scripts.

Now you are outside SAS. So this information is best gathered from your Linux or batch admin.

Data never sleeps

View solution in original post


All Replies
Super User
Posts: 5,429

Re: Launching SAS DI jobs using shell

Posted in reply to andreas_gryn

Deploy your DI job. The command line is part of the deployed jobs meta data.

Data never sleeps
SAS Employee
Posts: 75

Re: Launching SAS DI jobs using shell

Posted in reply to andreas_gryn

This user guide topic might be relevant: SAS(R) Data Integration Studio 4.9: User's Guide

The command-line  deployment tool enables you run an Ant script to deploy one or more jobs through a simple command-line interface.Use other software to schedule the job for execution.

Super User
Posts: 5,429

Re: Launching SAS DI jobs using shell

Posted in reply to DaveR_SAS

Interesting, I've managed to miss the feature.

But I think the OP asked for how to launch a deployed job, not launch the deployment itself. So I think your answer suits this thread better :

But when we are at the topic, the described process seems a bit tedious. And I wonder what kind of requirement led you to develop this? I have never been in a project were it made sense to auto-deploy jobs, especially in batch.

If you are looking to make promotion process easier, here are some wished for features (ideas free of charge... Smiley Happy ):

  • During import, make it possible to "automatically" deploy selected jobs
  • Have the promotion process integrated, so you don't have select items, export to file, change profile, open package, analyze, import, then seek and deploy jobs. Would be nice ta have all this in one wizard.
Data never sleeps
SAS Employee
Posts: 75

Re: Launching SAS DI jobs using shell

Thanks for your reply, Linus! I knew that your answer was simpler and  more direct than mine. But if you wanted to automate both the deployment and the execution of the job, I thought that you might be able to use the method in the topic above to deploy the job in batch and then use a scheduler to actually execute the job in batch. In any case, I'll pass your suggestions along to development. Thanks again for your patience and for taking the time to reply.

Super User
Posts: 5,429

Re: Launching SAS DI jobs using shell

Posted in reply to DaveR_SAS

Thanx, the pleasure is on my side Smiley Happy

Data never sleeps
Occasional Contributor
Posts: 10

Re: Launching SAS DI jobs using shell

Hi

Thank for all the input but I think you are talking about deploying and not executing.

When I deploy my SAS DI job I get my .sas file

I now want to execute it using a shell script.

Do you have an example/doc for this issue?

Thanks in advance

Super User
Posts: 7,796

Re: Launching SAS DI jobs using shell

Posted in reply to andreas_gryn

To run a SAS program stored as a .sas file in batch, you need the following commandline:

/path_to_sas/sas -config your_sasv9.cfg -autoexec your_sasv9_autoexec.sas -log your_logfile.log programname.sas

autoexec and config can/must be used to set an environment that corresponds to the environment your DI studio uses.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 10

Re: Launching SAS DI jobs using shell

Posted in reply to KurtBremser

Thanks.

I will implement this.

Is there also an easy way to capture the returncode of the job to use in errorhandling of the shell?

Solution
‎05-18-2015 03:29 AM
Super User
Posts: 5,429

Re: Launching SAS DI jobs using shell

Posted in reply to andreas_gryn

The shell script will return any SAS session RC. Whether it's easy or not capture this depends on how you will call/execute the scripts.

Now you are outside SAS. So this information is best gathered from your Linux or batch admin.

Data never sleeps
Super User
Posts: 7,796

Re: Launching SAS DI jobs using shell

Posted in reply to andreas_gryn

Immediately after the execution of a command, the shell assigns the return code to the environment variable "?".

So, the next line after the one that calls SAS should look like

RC=$?

Now you have stored the return code of the SAS job in RC (use $RC to retrieve the value) and can use it.

IE if I find RC=0, I check the log file for certain phrases that indicate errors that SAS will not flag on its own (some peculiar FTP protocol answers from IBM mainframes come to mind), and set special error conditions if I encounter one. RC

The last line of the shell script is then

exit $RC

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 10

Re: Launching SAS DI jobs using shell

Posted in reply to KurtBremser

Thanks for the helpfull info.

1 question I still have :-)

I have inserted this code and it works.

/sas/config/Lev1/SASApp/sas.sh -log /sas/common/Logs/test.log -sysin /sas/config/Lev1/SASApp/SASEnvironment/SASCode/Jobs/Jobflow_cons.sas

#----------------------------

# RETURN CODE

#----------------------------

STATUT=$?

Now I want to pass 2 parameters to the DI job.

How do I do that?

parameters are : ${MTH_REF}  and ${LOG_FILE}

Thanks again for the help

Super User
Posts: 7,796

Re: Launching SAS DI jobs using shell

Posted in reply to andreas_gryn

before the line where you call sas.sh, insert

export MTH_REF=xxxxxx

export LOG_FILE=yyyyyyy

Then you will be able to retrieve the values in SAS with the %sysget function.

Note the "export" command, which tells the UNIX shell to put the new environment variables in the global table, which is inherited by child processes.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 5,429

Re: Launching SAS DI jobs using shell

Posted in reply to andreas_gryn

You can build a shell script the meta data way in SMC Schedule Manager plug in. See online doc or help within the product.

Data never sleeps
🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 13 replies
  • 1559 views
  • 7 likes
  • 4 in conversation