user24872
user24872

Reputation: 99

Running a program in batch mode

I'm trying to open SAS in batch mode and I'm confused. I'm able to access SAS remotely from my computer from my school and I know how to open SAS interactively but it's too slow so the professor mentioned that we should use SAS in batch mode. Based on what I've read, opening SAS in batch mode is essentially opening a .sas file with the code.

I would open said file, like: sas filename.sas or sas filename (neither has worked for me). I keep getting invalid file. I saved the sas files in my documents. I'm working from a mac computer.

Upvotes: 1

Views: 11765

Answers (1)

Joe
Joe

Reputation: 63424

The basic concept of SAS batch mode operation in this kind of circumstance is that, rather than having your local PC constantly asking for things from the server, you just run SAS on the server directly without having to send information back to your local PC. This may or may not speed things up very much, but at least it won't have to bother updating you with its progress.

Normal SAS operation is you have a file in your local SAS DM window, you push a button, it sends the code to the server, which sends it to the SAS engine, compiles and runs it, creates some results files, and then gives you back the results. Batch mode is similar, except that you skip the first and last parts; you're in charge of them. You start with sending the code to the SAS engine (possibly including sending it to the server if you're not editing it there), and end with having results created on the server (but if you want to look at them, you need to open or download them on your own).

SAS can be run in batch mode simply by invoking it from the command line. The simplest version would be:

/path-to/sas sasprogram.sas

You can then add options, such as -log saslog.log and such to redirect the log (if you don't, then the log goes to the same location as the sas program file with the same name, just .log) or -config sasv9.cfg to use a custom config file. If you're running in unix, this page will help you.

If you're doing it in Windows, it's only slightly different.

c:\path-to\sas.exe -sysin sasprogram.sas

I don't know why sysin is necessary in windows and not unix. Probably a default thing. This page should be a good start, or you can go to the sascommunity.org page on the subject.

A good idea is to set up a batch or shell script file that does your custom options for you. In Windows that's a .bat file, in Unix that's a .sh or similar file. That way you can simply type sas sasprogram.sas and it will run your sas program with the default options the way you like them.

When you're doing this, remember that you are executing this all on the server, and your desktop or laptop is not involved (except as a telnet terminal or whatever you're using to remote into the server). You cannot see your local drives. Everything has to be sent over to the server first, either by FTP or by saving on network storage that is also accessible on the server. Unless your desktop's hard drive is mounted on the server (unlikely) it's not visible.

Upvotes: 3

Related Questions