我有多个每月运行的 SAS 代码。我想要一个包含所有代码并且可以从中运行每段代码的 excel 电子表格。
首先,是否有一种简单的方法可以做到这一点?我假设它只会调用代码位置并从那里运行它?我需要什么特别的参考资料吗?
我找到了这段代码并一直在尝试使用它,但我认为有问题,因为它告诉我许可证已过期,但是当我在 excel 中运行它时代码可以工作。
这是VBA代码:
Sub RunSAS()
'--> Verify Run Request (Exit If Cancelled)
a = MsgBox("Run " & ActiveCell.Value & "?", vbOKCancel, "Run SAS Program Confirmation")
If a = vbCancel Then
Exit Sub
End If
'--> Run SAS Program
Z = Shell("C:\Program Files\SAS\x86\SASFoundation\9.3\sas.exe -initstmt '%include """ & ActiveCell.Value & """ / source2; run;'", vbNormalFocus)
'--> If Requested, Insert Run Time/Date In FIFO Order
' ('Run History' Must Appear In First Row Of Column To Right Of Program Name)
If UCase$(Trim(Cells(1, ActiveCell.Column + 1).Value)) = "RUN HISTORY" Then Cells (ActiveCell.Row, ActiveCell.Column + 1).Select
Selection.Insert Shift:=xlToRightCells(ActiveCell.Row, ActiveCell.Column + 1).Select
Selection.Copy Cells(ActiveCell.Row, ActiveCell.Column - 1).Select
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Selection.Value = Date & " " & Time()
Cells(ActiveCell.Row, ActiveCell.Column - 1).Select
Application.CutCopyMode = False
End If
End Sub
我尝试执行的 SAS 代码非常简单,只是尝试给自己发送一封电子邮件。
%INC 'H:\sasconnect\idwapid.inc';
OPTIONS COMAMID=tcp;
FILENAME RLINK '\\int\groupdata\IDW\sasscript\SAS93\sasap6\prod\Res_sasapv93_prod.scr';
%let host=idwap1 17554;
%let server=host;
SIGNON remote=&server;
RSUBMIT;
*** send email ***;
FILENAME eml2 email TO= ("a.m@company.com.au") SUBJECT="Test";
DATA _NULL_;
FILE eml2;
PUT "Email 3";
RUN;
endrsubmit;
signoff;
任何帮助,将不胜感激。