DATA Step, Macro, Functions and more

Can I use an external program/console/other to submit my SAS programs?

Reply
Occasional Contributor
Posts: 16

Can I use an external program/console/other to submit my SAS programs?

Not sure if this is a SAS question (if it's not just let me know and I can delete the thread), but at my job we have like 7 SAS programs that we submit one by one by right clicking and hitting "Batch Submit" button. I've tried to consolidate the 7 programs into one that can be submitted at once but i think the need to be run individually in order. My question is, is there some way to submit those jobs using some sort of dashboard or console that has buttons or something similar? Maybe like a VBA button in Excel? Management says they don't like having people right clicking and hit submit, so they want a easier, more user friendly way for this to occur. Ideally I would build other functionality into this dashboard eventually but just want to see if anyone has thoughts on batch submitting jobs via some sort of external internface. 

 

Any other articles or links about automating SAS jobs would be awesome. For example, can you submit a job automatically based on a schedule? 

 

Very new to SAS so trying to get a feeling for what is possible and what is not.

Super User
Posts: 7,854

Re: Can I use an external program/console/other to submit my SAS programs?

First question: do you run SAS locally or on a server? If on a server, which operating system?

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

Re: Can I use an external program/console/other to submit my SAS programs?

Posted in reply to KurtBremser

We run it on a Remote Desktop Server. Windows Server 2012 R2 Standard, 64 bit. Would LOVE if people could submit stuff outside the server environment, but don't think that's possible so don't mind having people log into the server to "submit" the jobs (aka click the buttons) in the example I describe above.

Super User
Posts: 7,854

Re: Can I use an external program/console/other to submit my SAS programs?

I'd simply create a batch file that runs all jobs in succession, then create a link for it, and put that on the desktop.

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

Re: Can I use an external program/console/other to submit my SAS programs?

Posted in reply to KurtBremser

What do you mean by "A link on the desktop"? Would they still have to right click and hit batch submit?

 

Also in terms of consolodating those jobs into one step, do you have any sample code on how something like that could occur. Also does it matter that the steps are dependent on one another? Meaning, if job 1 creates a file that job 2 needs in order to execute successfully, would that be a problem in terms of writing a script that combines them all at once?

Super User
Posts: 7,854

Re: Can I use an external program/console/other to submit my SAS programs?


bzubrick wrote:

What do you mean by "A link on the desktop"? Would they still have to right click and hit batch submit?

 

Also in terms of consolodating those jobs into one step, do you have any sample code on how something like that could occur. Also does it matter that the steps are dependent on one another? Meaning, if job 1 creates a file that job 2 needs in order to execute successfully, would that be a problem in terms of writing a script that combines them all at once?


A Windows batch file (like a shell script in UNIX) is just a text file that contains commands, just like commands you type into a cmd window.

Consider this:

"C:\Program Files\SASHome\SASFoundation\9.4\sas" -sysin C:\Programs\program1.sas -log C:\Logs\program1.log
"C:\Program Files\SASHome\SASFoundation\9.4\sas" -sysin C:\Programs\program2.sas -log C:\Logs\program2.log
"C:\Program Files\SASHome\SASFoundation\9.4\sas" -sysin C:\Programs\program3.sas -log C:\Logs\program3.log

Save that as (eg) C:\scripts\mysas.bat.

Then (in the Windows explorer) right-click on that mysas.bat, and select "Create Link". Then drag&drop that link onto the Desktop.

 

Once you double-click that link, the programs will be run in succession. In a batch file, you can also add conditions so that later programs will only run if the previous returned successfully. Just google "windows batch conditional execution" to find some hints.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Trusted Advisor
Posts: 1,584

Re: Can I use an external program/console/other to submit my SAS programs?

You need run your programs batch.

You can do it by scheduling scripts to run at any periods.

 

If you need examples of how to write rhe scripts you have to give informatin of your Opereating Sysytem -

is it WINDOWS or LINUX or other and which version.

Occasional Contributor
Posts: 16

Re: Can I use an external program/console/other to submit my SAS programs?

We run it on a Remote Desktop Server. Windows Server 2012 R2 Standard, 64 bit.
Trusted Advisor
Posts: 1,584

Re: Can I use an external program/console/other to submit my SAS programs?

I'm not familiar with writing windows scripts, anyhow you need prepare next parameters:

 

1) server name

2) server path to sas executable file (.exe)

3) sas configuration file, adapted to run batch, its path and name - on server

4) sas autoexec file (with libnames, filenames, etc.)

5) sas log file to save/replace - path and name

5) sas program - path and name - ready to run

 

Does windows scheduler enambles define order of submitting jobs ? 

 

After preparing the scripts enter them in right order and linkage in the scheduler.

 

You may add in the programs checking existence of input files and datasets, if need.

Frequent Contributor
Posts: 119

Re: Can I use an external program/console/other to submit my SAS programs?

Simple answer is yes, I have done it many times both graphically (button on desktop app, as an add-in to SAS EG, as an add-in on Excel) as well as using cmd files. I would recommend not using cmd/bat files. They do work but I would focus on using PowerShell in Windows.

 

For a Windows app (UI), it is a lot easier to do this if you have SAS integration technology. Chris Hemendinger does a lot of blog posts on this area so look for his stuff.If you have SAS EG, Also, consider buying his book. 

 

Personally, I stand it up using C#, mostly using web services but the techniques are the same regardless of whether you use VBA, C#, VB.NET, PowerShell, etc. 

 

Ask a Question
Discussion stats
  • 9 replies
  • 150 views
  • 3 likes
  • 4 in conversation