- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I want to run a sas program in batch mode and have the .log and .lst file saved in the same directory as the .sas file.
However, the file associations seem to have been messed up on our Windows 2008 server (SAS 9.2 64bit). There is no 'Submit in batch mode' option and if I right click on the program test.sas and choose "Open with SAS 9.2 for Windows" I get the error message:
Error: Insufficient authorization to access C:\Window\system32\test.log
Similarly, if I create a batch file with command "c:\program files\SAS\SASFoundation\9.2\sas.exe" %1
and choose this, I get the same error message.
I don't have admin access to this server, but it seems to me that this should be possible by using an appropriate batch file. Any suggestions? (Incidentally, SAS works fine in interactive mode if I start it from the program menu).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The following might be of help: http://support.sas.com/kb/10/856.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You will probably need to work with your server administrator on this. He has modified the working environment from the default delivered by SAS.
The error associated with "Open with SAS 9.2 for Windows" is because it is trying to open interactive SAS and direct the log to the system32 subdirectory. In a lot of offices, the system32 subdirectory is read-only by Windows policy. If so, the note that Art cites will not help.
A workaround that you might be able to do is to modify the right-click behavior on .sas files to mimic the conditions that are used in the SAS icon. In windows explorer, go to tools --> folder options and go to the SAS file type. You can create a new right-click option and the paste and modify the string from the interactive icon. (This depends on how tightly controled your desktop is.)
Doc Muhlbaier
Duke
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
you can add the -log option to define a different location for the log output that is in a properly writable directory. Also if executing in batch mode you should also use the -batch option.
c:\program files\SAS\SASFoundation\9.2\sas.exe -batch -log c:\mylog.log -sysin c:\mypgm.sas -print c:\mylst.lst -sysparm My Passed Paramameter
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I knew about the solution proposed by FriedEgg, however it doesn't fully solve the problem. I want the log file to automatically have the same name as the submitted program (apart from the extension).
(The approach suggested by Doc@Duke doesn't work in Windows 7 or Server 2008 - the ability to configure file type associations has been removed from the user interface)
I presume there must be a way to create the log file name and location within a batch file using some scripting language, but surely there must be a way of asking SAS to do this (since that is what it normally does).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Actually, I've discovered the scripting is not that hard. A batch file with the following single line seems to do the trick
"c:\program files\SAS\SASFoundation\9.2\sas.exe" %1 -nologo -batch -log "%~dpn1.log" -print "%~dpn1.lst"
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Basically this is the direction I was meaning for you to take my post. Here is another example:
$cat example.bat
@echo off
if NOT (%1)==() GOTO RUN
ECHO ----Batch Program Notes----
ECHO Required Parameters:
ECHO [program_fullpath]
ECHO ---------------------------------------
GOTO END
:RUN
for /F "tokens=2,3,4 delims=/ " %%i in ('date/t') do set d=%%k%%i%%j
for /F "tokens=1,2,3 delims=:. " %%i in ('time/t') do set t=%%k%%i%%j
"C:\Program Files\SAS\SASFoundation\9.2\sas.exe" -batch -nologo -sysin "%1" -sysparm "%*" -log "%~dpn1_%d%_%t%.log" -print "%~dpn1_%d%_%t%.lst"
:END
Wow, it has been a long time since I have thought about windows bats. I prefer *nix.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I've now come across another problem. I start my SAS program with a batch file with
"c:\program files\SAS\SASFoundation\9.2\sas.exe" %1 -nologo -batch -ls 130 -config D:\SAS\SASV9.cFG -log "%~dpn1.log" -print "%~dpn1.lst"
The log file now has the error
NOTE: Writing Body file: sashtml.htm
ERROR: Insufficient authorization to access C:\Windows\system32\sashtml.htm.
WARNING: No body file. output will not be created.
When I start SAS interactively, it has the results being directed to the Work folder (which is located elsewhere). How do I control this in the batch job?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Setting the option SASINITIALFOLDER fixed this. Would be nice if there was a document which brought together all the options on how to start SAS in the windows environment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
BruceBrad,
I got the same error, when trying
ods html image_dpi=600;
Any idea how you corrected this sashtml.htm error?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Bruce,
On "(The approach suggested by Doc@Duke doesn't work in Windows 7 or Server 2008 - the ability to configure file type associations has been removed from the user interface)", that is still there in Win 7 (I don't use Winserver to check). It appears that your windows network administration got a bit overzealous with the policy editor.
Doc
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Doc, do you mean under control panel/programs/default programs? You can do some things there, but not (it seems) control parameters associated with programs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
No, under tools --> folder options . That's where you can add/modify the file associateions in windows.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bruce
I use a bat file to set pgm, log and output like this-
set sas=C:\Program Files\SAS\SAS 9.1\sas.exe
set src=C:\SAS\Source\
set log=C:\SAS\Log\
set prt=C:\SAS\Output\
"%sas%" "%src%testpgm.sas" -nosplash -print "%prt%" -log "%log%"
exit
That way they'll all be named the same as the program
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The real problem is the directory that Windows is using as the current working directory when it starts SAS.
If you open a Command Window and move to the directory with your program in it and type the command:
> "c:\Program Files\SAS\SAS 9.2\sas" myprogram
It will run SAS 9.2 in batch using myprogram.sas as input and writing the log to myprogram.log and output to myprogram.lst.