我每月都会运行多个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;
任何帮助都将不胜感激。
答案 0 :(得分:0)
您听说过“适用于Microsoft Office的SAS®加载项”产品吗?详情请见http://support.sas.com/software/products/addin/