|

Batch SAS or What’s a Sea Prompt?

At SAS Global Forum, someone commented to me that he was stunned at the number of people who were unfamiliar with a c:\

Yes, young people, when us oldsters say “c prompt” we are not talking about a cool shellfish

king crab

Nope, my dears, in Windows, we expect you to go to that window start menu, click on All Programs, then pick Accessories and then there is something called a Command Prompt.

Don’t feel bad if you don’t remember it. I barely remember it myself.  I use SAS On-Demand a lot with my classes. I have a pretty awesome new computer so even with very large data sets I can run things pretty quickly just by clicking on that little running guy.

BUT … every now and then I end up with a job  that not only takes a long time but fills up the entire output buffer. I don’t want to clear my log file. I want to read it later.  So.. enter batch SAS

It’s very simple if you remember a few things.

1. Go to the directory where your SAS program is located. To do this, you most likely need to change directory from the top-level C:\   To do that, say your file is in a directory called MySASFiles in your documents folder, do this:

cd \users\you\documents\MySASFiles

obviously, you want to put your name instead of  “you”.

Unlike Unix, Window is not case-sensitive

2. Remember that if you have a space in the directory name you need quotes and, unfortunately, SAS is almost certainly stored in the Program Files directory. Also, remember to end the quote at the end of the whole path, that is, at the end of your file name, so you are going to write the whole statement on one line (don’t worry if it wraps around by itself) like this

“c:\Program Files\SAS\SASFoundation\9.2\sas.exe” -sysin programname.sas -config “c:\Program Files\SAS\SASFoundation\9.2\sasv9.cfg”

With the -sysin and -config, make sure you have no space between the – and the word that follows.

Then hit enter. The log and lst files will automatically be named programname.log and programname.lst and be created in the directory where your programname.sas file is.

That’s it. Go have a martini. Come back when you are sober and look at your results.

Similar Posts

2 Comments

  1. And of course, if you want to run a SAS program in batch you can do this from the Windows Explorer by right-clicking the program and choosing “Batch Submit with SAS 9.2”.

  2. One alternative you might consider is the PrintTo Procedure, you can use it to explicitly redirect the log and output to text files.

    With some simple macro coding you can encapsulate the logic to start logging at the top of a program, end logging at the foot of the program, parse the log for errors, and then email a synopsis of the log [there are n(o) errors, n(o) warnings], with the full log and output as attachments.

    Then you can read the output and log with smartphone in one hand and martini in the other.

    Rob

Leave a Reply

Your email address will not be published. Required fields are marked *