06-18-2015 11:31 AM
Hi ... I have several issues in trying to set up a batch mode .bat file to run 78 progams.
1. Able to create a .bat file from the CMD in start;
2. Cannot successfully re-create a .txt file (I did it once); not clear; Am able to create a listing of the programs I want to run in CMD and can copy but want .txt;
at the prompt I enter the location
3. When I run the .bat file it appears and then quickly goes away...as though its running, but I check output and nothing in the master output excel file. Understand the window should remain open for duration of program run. This part I have jingled with for too long. I cannot seem to get the proper path to SAS on my machine nor to use " quotes or not. Since there are spaces in the address!? In addition, to run consecutively use "startw/..."
4. I want to run:
Startw/ "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\SAS\sas.exe" -sysin C:\Users\genius\Documents\Tables\tables9.sas
There are 78 programs to run and this one is a test.
5. Create the txt file to list all my programs...
The folder Tables contains all the programs...I have tried this ALL ways but the correct way.
I have been using two SUGI helps and unable to finish the job.
I appreciate your responses and apologize if I have missed a thank you!
06-18-2015 12:53 PM
5: The command would be dir C:\Users\genius.not\Documents\Tables\*.sas C:\Users\genius.not\Documents\Tables\tables.txt
to list all of the SAS program files in that named folder and put there information into a file named tables.txt options on the DIR command can add or reduce elements in the text file.
You need to expand on 1, 2.
3 may depend on HOW your are running the batch file
4 looks like SAS may not find the configuration file ; I have no idea what STARTW/ may be. I don't think it is a standard batch option/ command.
06-18-2015 01:32 PM
What I know:
Strive for clarity so forgive me for not getting this across better...1-3 were really more of what I already understand and where I am.
1 .TXT file - for the listing of 78 programs from my tables folder.
I am able to create a listing but only in CMD not as a txt...so I am missing something. I used dir C:\Users\genius.not\Documents\Tables\*.sas C:\Users\genius.not\Documents\Tables\tables.txt but did not get an .txt in that location...still trying. The key was *.sas that I did not know....thank you.
2 .BAT file -using the txt file to insert the list of programs to my .bat file
I am able to create a .BAT file but not one that runs successfully. I do believe the problem is in identifying the correct path for sas. There are two suspects a .exe and .cfg. The .cfg has the most recent...have tried both. Also tried with quotes and without. the "STARTW/" is the syntax that runs these programs.
I am on program #44 so I am hope to figure this out before I finish, regardless theres another year of data in the queue.
06-18-2015 01:51 PM
I am not clear on what you mean by " only in CMD not as a txt"
Do you mean that when you type the command in a CMD window that it works?
dir C:\Users\genius.not\Documents\Tables\*.sas > C:\Users\genius.not\Documents\Tables\tables.txt
If looks like my previous response lost the >
that line in a text file with the .BAT extenstion when clicked on should create the txt with the directory listing.
06-18-2015 02:10 PM
I meant I could see the listing in the CMD.exe window HOWEVER using the ">" was a bingo Thanks so much.
The file does not easily convert to inputting the program names since there are other variables....date, time, size even though I removed those details, guess I'll just use input @ syntax which I'm not strong with. I'll be fine.You would think I could generate just the vars I need... program name and file type. (.sas).
Now running a .bat file....several papers show the syntax as:
STARTW/ C:\"Program Files"\SASHome\SASFoundation\9.4\sasv9.cfg -sysin C:\Users\kind.you\Documents\Tables\tables9.sas
This is tricky since its been a challenge to identify the location of my sas.exe or .cfg and I have tried repeatedly both, and sans quotes....some papers show quotes in different places so I have tried a variety. Understand what its doing, telling sas to start running the program(s) and to bring them into the system from the next path. I get a quick cmd.exe window that looks like it might work but I understand it should remain open while the program runs.
Thanks so much!
06-18-2015 05:00 PM
If you search for the syntax on the DIR command you will find switches to do things like just show the file name without the summaries. You may want the Dir /b.
If you have a desktop icon to start SAS right click on it, go to the properties menu item and look in the target box that should the executable path and config information. Basically just copy into the batch file.
06-19-2015 07:51 AM
File names without summaries was what I was hoping would be available...I will review commands more closely.
Going to properties and locating the target/location is not something new to me, but I have found myself in a circle of attempts because my first attempt did not succeed...leading me to believe its likely something else in the syntax that I am doing wrong. I hope to get back to starting over today.
You're help is great...thanks.
06-18-2015 09:38 PM
Try to break up the big problem into little problems, solve them one by one and then put everything together.
1) Get a DIR command with the switches you need to only list SAS program files. This should be something like: DIR /b c:\test\*.sas
2) Get the command for batch submitting a SAS program right. If you have an environment set-up then you probably want to use the OOTB sas.bat instead a sas.exe as this also calls the right autoexec and config files for you.
C:\SAS\Config\Lev1\SASApp\sas.bat -sysin ..... -log ..... -print ..... -noicon -nosplash
3) Once you have 1 and 2 working set-up your script so that it creates a directory listing and then generates the batch commands using the names from this listing (of if this is a static once-off: simply repeat your working batch command line calling the different SAS programs).
06-19-2015 07:57 AM
Patrick, wise advise...I often forget...breaking up the problem!
1. will look at DIR commands today for my preference.
2. Agree to solving my SAS program location for submission accurate--key.
In summary, I feel like this is likely not that difficult but first times can be a challenge. I value the help here from all...thank you. I have to complete another assignment for these programs, but will get back to trying these attempts today.
06-30-2015 06:34 PM
Great! Finally got back to working this process and successfully output the files to a .bat file. Wow! Onward... Am documenting this little process, since this is new to me, DIR syntax and switches...nice.
07-08-2015 01:35 PM
This .bat file ran successfully (with my 3 pgrms executing properly) however there are 75 program names t1-t75...I imagine there exists a method by which I do not have to edit this syntax(copy paste edit) but rather direct the .bat file with one command to invoke/exe SAS and then run the series of programs, that are listed solely from a txt file successfully created to list all the prgms in the folder.
If there is a paper on this, please direct me. I am still searching.
[.bat file-code that ran great!]
"C:\Program Files\SASHome\SASFoundation\9.4\sas.exe" -sysin C:\Users\name\Documents\BatchProcessing\Test\t1r.sas
"C:\Program Files\SASHome\SASFoundation\9.4\sas.exe" -sysin C:\Users\name\Documents\BatchProcessing\Test\t3.sas
"C:\Program Files\SASHome\SASFoundation\9.4\sas.exe" -sysin C:\Users\name\Documents\BatchProcessing\Test\t2.sas
Sample listing in a separate .bat file.
Thank you for all your help.
07-08-2015 01:53 PM
If all of your SAS programs are in one folder and you want to run ALL of them the SAS program that should be in your in Batch job could look like this:
This would call and run each of the programs. If sequence is important then the names should be able to sort in the order you want, so T05.sas instead of t5.sas as T5 is after T40.
Or you could have multiple include statements:
But these would all be in the single file called by the batch process.
07-08-2015 02:21 PM
Ballard, I tried a couple of different methods based on what you indicate, likely user error, since this is very new.
"C:\Program Files\SASHome\SASFoundation\9.4\sas.exe" %include "C:\Users\name\Documents\BatchProcessing\Tables\*.SAS"
"C:\Program Files\SASHome\SASFoundation\9.4\sas.exe" %include "C:\Users\name\Documents\BatchProcessing\Tables\*.SAS";
"C:\Program Files\SASHome\SASFoundation\9.4\sas.exe" -sysin %include "C:\Users\name\Documents\BatchProcessing\Tables\*.SAS"
.bat and I are still fighting over this...help! (Thank you!)
07-08-2015 04:03 PM
1) Create a SAS program file called SASBatch.SAS or some such.
2) Put the %include statements in SASBatch.SAS
3) Run the batch job as "C:\Program Files\SASHome\SASFoundation\9.4\sas.exe" -sysin C:\Users\name\Documents\BatchProcessing\Test\SASBatch.sas
This approach does have the possible advantage of sharing the same work space so things like library assignments and such only need to be done in the first %include file. Possible disadvantage is larger LOG files.