SAS中文论坛

 找回密码
 立即注册

扫一扫,访问微社区

查看: 913|回复: 0
打印 上一主题 下一主题

一段很好的代码范例:SAS与Windows交互

[复制链接]

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
楼主
 楼主| 发表于 2007-4-20 19:58:18 | 只看该作者

一段很好的代码范例: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]
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SAS中文论坛  

GMT+8, 2025-6-13 19:56 , Processed in 0.069752 second(s), 20 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表