DATA Step, Macro, Functions and more

execute sas program via command line

Accepted Solution Solved
Reply
Regular Contributor
Posts: 201
Accepted Solution

execute sas program via command line

Hi,

 

I am using SAS on a server via Enterprise Guide. Can I also execute a SAS program on my local machine via the command line? Any pointer would be very much appreciated. Thanks.

 

Christian


Accepted Solutions
Solution
‎03-01-2018 09:05 AM
Regular Contributor
Posts: 201

Re: execute sas program via command line

Hi all,

 

I have got it to work using IOM in the end see:

 

http://support.sas.com/resources/papers/proceedings12/017-2012.pdf

 

I can write from Windows to the Unix file system and then use an include. The steps are generate SAS code, write it to file. Use include and IOM to execute SAS code. The SAS code writes to the file system as well, which I can see in Windows. Data can then be uses in C# code.

View solution in original post


All Replies
Super User
Posts: 5,826

Re: execute sas program via command line

Posted in reply to csetzkorn
If the server and the client uses the same OS, and you can map server drives it's possible.
But why?
You can execute E.G. projects locally, it still the SAS session will execute on the server.
Data never sleeps
Regular Contributor
Posts: 201

Re: execute sas program via command line

Thanks. Basically, I want to create SAS programs (text files) dynamically (via another program) and then execute the via the command line (in invoked by the program that creates the text files). EG runs on Windows and SAS in Unix, as far as I know. No chance that I can map any drives - our IT is pretty useless. I was also thinking about using stored processes. Ultimately, a stored process is a (restful?) API. This may work in theory but determining the URI of the stored process and authentication may be impossible - I do not expect any support from our IT. Thanks.

Regular Contributor
Posts: 195

Re: execute sas program via command line

Posted in reply to csetzkorn

That's a really bad situation you are in. If you name an Processflow "autoexec" in EG, it will automatically run on loading the project - you have to check an option for the automatism to happen. This is a workaround and not a very good one, but the only one i can think of that does not need the IT involved. Can you create a stored process?

Regular Contributor
Posts: 201

Re: execute sas program via command line

Posted in reply to error_prone

Thanks I can create stored processes, although there is no clear target operating model (e.g. best practice of deployment). I would also need to know the URI of my stored process. Is there a way of determining this? I intend to write a C# application to consume this. Another alternative is IOM. I once got some C# code working using IOM as a POC. Thanks!

Super User
Posts: 3,765

Re: execute sas program via command line

Posted in reply to csetzkorn

You can only execute a SAS program on your PC if you have Foundation SAS also installed there. If this is the case then the option "local server" should display when you configure your EG connection profile. If you do have this then just make the local server your active one and you can still use EG to run code locally.

 

If what you mean is: can you run a command line process that will run a SAS program on your remote SAS server? Yes that is possible and one of the options would be the EG scheduling facility.

PROC Star
Posts: 2,220

Re: execute sas program via command line

Posted in reply to csetzkorn

If your only link to the SAS server is EG (i.e. no FTP, no mapped drives, no access to the unix shell from windows, no windows SAS on your PC to talk to the server SAS) then the only way to create or modify or delete or run anything on the unix server is via this interface: EG.

 

In this case, this is not a SAS question, it is a general IT question. If you only have one access method, you can only use this one access method.

Regular Contributor
Posts: 201

Re: execute sas program via command line

Thanks ChrisNZ. I guess I could use a desktop equivalent to Selenium (a web driver). I also got IOM working to execute some code (see http://support.sas.com/resources/papers/proceedings12/017-2012.pdf). Unfortunately, nothing happens not even an error message. IOM can also be used to invoke stored processes. i will have a look at this ...
Super User
Posts: 9,560

Re: execute sas program via command line

Posted in reply to csetzkorn

You can script a SSH client on the Windows side so that it automatically logs on to the UNIX server and executes a command there, that command then being a call of the sasbatch.sh script provided in the SASApp configuration tree.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Regular Contributor
Posts: 201

Re: execute sas program via command line

Posted in reply to KurtBremser
Thanks KurtBremser. I won't get access to the server or can I use my SAS credentials to authenticate?
Super User
Posts: 5,826

Re: execute sas program via command line

[ Edited ]
Posted in reply to csetzkorn

@csetzkorn id not already did, you need to talk to your SAS server admin, and potentially UNIX/AD admin and an IT architect so you are not trying to implement a "bad" practice.
If you have a valid use case you should be able to set this up on the server. Driving jobs/batches from local machine is a 20th century thing.

Data never sleeps
Solution
‎03-01-2018 09:05 AM
Regular Contributor
Posts: 201

Re: execute sas program via command line

Hi all,

 

I have got it to work using IOM in the end see:

 

http://support.sas.com/resources/papers/proceedings12/017-2012.pdf

 

I can write from Windows to the Unix file system and then use an include. The steps are generate SAS code, write it to file. Use include and IOM to execute SAS code. The SAS code writes to the file system as well, which I can see in Windows. Data can then be uses in C# code.

Super User
Posts: 3,765

Re: execute sas program via command line

Posted in reply to csetzkorn

Do you have access to SAS Management Console? If you do there is a much easier way. SMC allows you to run SAS batch jobs on your Unix server via a point-and-click interface.

Regular Contributor
Posts: 201

Re: execute sas program via command line

No - I am just a proletarian SAS consumer
☑ This topic is solved.

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

Discussion stats
  • 13 replies
  • 312 views
  • 5 likes
  • 6 in conversation