DATA Step, Macro, Functions and more

Run SAS code remotely on a Linux server

Reply
Occasional Contributor
Posts: 8

Run SAS code remotely on a Linux server

Hi,

I need to run SAS code remotely on a Linux server.

I have a code that runs a long time, and I need to execute this code on the remote machine (Linux), without using the remote desktop connection, so I can turn off my local computer and let the code process remotely.

 

Could you please suggest if there is a way how this can be done, if possible?

 

Thanks a lot in advance.

 

With best regards,

RD 

Super User
Super User
Posts: 7,984

Re: Run SAS code remotely on a Linux server

Is SAS installed on the Linux server in any form?

Occasional Contributor
Posts: 8

Re: Run SAS code remotely on a Linux server

Yes, SAS is installed on the Linux server.

Super User
Posts: 7,852

Re: Run SAS code remotely on a Linux server

With a server-based SAS, you usually have the configuration tree somewhere (BI Server). Something like /sasconf/Lev1/.....

Within that, you find the subtree for the SASApp application server; within that, there's a Batchserver directory that contains the sasbatch.sh script.

This shell script can be used to run batch jobs in the context of the SASApp server.

 

Convert your SAS code to a .sas file; save it in an appropriate place (eg subdirectory sasprog in your home directory)

Do a test run (maybe with a smaller program that finishes quickly):

/sasconf/Lev1/SASApp/BatchServer/sasbatch.sh $HOME/sasprog/myprog.sas -log $HOME/sasprog/myprog.log

Review the log file. If everything is OK, you can apply this to run in the background:

nohup /sasconf/Lev1/SASApp/BatchServer/sasbatch.sh $HOME/sasprog/myprog.sas -log $HOME/sasprog/myprog.log &

The & at the end redirects the job into the background; running it with nohup means that a disconnection of the telnet/ssh connection will not terminate the job. Any stdout output will be directed to the file nohup.out in the directory from where you called that commandline.

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

Re: Run SAS code remotely on a Linux server

Posted in reply to KurtBremser
Thanks a lot KurtBremser!
Super User
Posts: 7,852

Re: Run SAS code remotely on a Linux server

Note that it is necessary to supply absolute path names for programs and logs (starting with a forward slash). $HOME provides this (resolves usually to /home/username)

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 7,852

Re: Run SAS code remotely on a Linux server

If that remote Linux server is your SAS server, then look at background processing (with &) and the nohup command. You have to convert your SAS code to a batch job first (a .sas file that contains all your code and will run from the command line; additional use of configuration will be necessary, depending on your SAS environment)

If SAS is not on the remote server, no luck.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 6 replies
  • 146 views
  • 0 likes
  • 3 in conversation