SAS中文论坛

标题: 一段很好的代码范例:SAS与Windows交互 [打印本页]

作者: shiyiming    时间: 2007-4-20 19:58
标题: 一段很好的代码范例:SAS与Windows交互
[code:0859a]@echo off
Rem - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Rem Copyright (c) 2004 by SAS Institute Inc., Cary, NC 27513
Rem Name:  sasbat.bat
Rem Doc: Run SAS on Windows with proper options for SAS IT
Rem      Resource Management batch mode
Rem
Rem Usage: sasbat.bat infile
Rem    where "infile" is the simple (path is not required
Rem    if in the current working directory)
Rem    first name of the files read and written by SAS:
Rem       .sas is appended to "infile" for the input program
Rem       .log is appended to "infile" for the SAS log
Rem Example: cd \mypgms
Rem          sasbat.bat mysaspgm
Rem - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
set INFILE=%1%

Rem The following line is broken into three lines so that you can
Rem  see the right end of the command. Make these three lines into
Rem  a single line before you run.
"C:\program files\sas\sas 9.1\sas.exe" -sysin %INFILE% -awstitle "SAS ITRM Batch" -icon -nosplash -noxwait -noterminal

Rem Note common exit codes
Rem The following line is broken into two lines so that you can
Rem  see the right end of the command. Make these two lines into
Rem  a single line before you run.
for %%c in (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16) do if errorlevel %%c set EXITCODE=%%c

Rem Did SAS terminate gracefully?
Rem The following line is broken into two lines so that you can
Rem  see the right end of the command. Make these two lines into
Rem  a single line before you run.
find "NOTE: SAS Institute Inc., SAS Campus Drive"
      %INFILE%.log > nul
if not errorlevel 1 goto NORMTERM
echo SAS was interrupted before completing termination processing.
goto EXIT

:NORMTERM

Rem Go scan log when exitcode is 0 or 1.
if %EXITCODE%==0 goto SCANLOG
if %EXITCODE%==1 goto SCANLOG

:ERRORS
echo SAS terminated with errors (EXITCODE ge %EXITCODE%).
goto EXIT

:SCANLOG
Rem Scan the SAS log since we might still have errors with
Rem  zero exitcode.
find "Errors printed on page" %INFILE%.log > nul
if not errorlevel 1 goto ERRORS
echo SAS terminated without errors (EXITCODE eq %EXITCODE%).
goto EXIT

:EXIT
%echo on[/code:0859a]




欢迎光临 SAS中文论坛 (https://mysas.net/forum/) Powered by Discuz! X3.2