簡體   English   中英

SAS批處理作業:通過同一本地服務器連接執行多個腳本

[英]SAS batch jobs: executing multiple scripts through the same local server connection

當執行一個.sas腳本時,我在“建立與本地服務器的連接”和庫加載上花費了大約30秒鍾,然后執行了3秒鍾執行sas腳本本身。

是否可以針對同一已建立的連接以編程方式(通過Windows Shell調用它們)執行多個sas腳本?

像保持活動的TCP通道一樣?

您好access_granted,

您走在正確的軌道上。 您在對RawFocus的評論中說:“它像套接字服務器一樣工作”,而在您的問題中,“保持活動的TCP連接”。 您實際上可以通過一些巧妙的編程將其歸檔在SAS中。

SAS套接字服務器:這是使用宏語言的SAS服務器,它會永遠循環以響應請求。 值得注意的是,在等待下一個請求時,服務器處於睡眠狀態,僅占用其主機上的很少的資源。

/* Port as input parameter */
%let portno= &sysparm;
%* let portno= 001;
%do %while ( 1 );
filename in_msg SOCKET " :&portno"
SERVER;
filename temp_pgm  "%sysfunc(pathname(work))/a-ready.sas" ;
data _null_;
infile in_msg;
 file temp_pgm;
 input ;
 put _infile_;
run;
filename in_msg;
/* Before execution, server can choose to
parse it first */
%inc temp_pgm;
run;
filename temp_pgm;
%end;

該客戶端提供了SAS服務器的IP地址,要調用的端口號以及服務器要執行的程序文件。 它能夠將一個請求發送到已知的可用SAS服務器。 還要注意,客戶端負責引導服務器在哪個端口上發送結果(如果需要)。

%let host= IP-address-for-server-machine;
%let portno= 001;
filename to_servr SOCKET “ &host:&portno” ;
filename input ‘SAS-program-to-be-run-onserver.sas’;
/* Simple scheme to come up with a different port
number to accept response from the server */
%let ret_port= %eval( &portno + 1 );
data _null_;
 file to_servr;
infile input end= EOF;
if _n_ = 1 then do;
/* Required info for the server to return results
back to this client */
 put ‘%let ret_port= ’ “ &ret_port;” ;
 put ‘%let client= IP-address-for-clientmachine;’;
end;
input ;
 put _infile_;
run;
filename input;
filename to_servr;
/* Receiving socket for the results */
filename back_rst SOCKET “ :&ret_port” SERVER;
data null_;
infile back_rst;
 file print;
 input ;
 put _infile_;
run;
filename back_rst;

資料來源: http : //www2.sas.com/proceedings/sugi24/Coders/p083-24.pdf

順便說一下,如果可能的話,您也可以考慮重新配置SAS服務器。 啟動會話需要30秒,這有點長,尤其是對於批處理會話。

如果您希望它們在同一個sas 會話中連續運行,則可以創建一個sas腳本來執行其他腳本。

options source2; /* puts the contents of the sas files below in the log */
%inc "C:\MyLoc\script1.sas";
%inc "C:\MyLoc\script2.sas";
%inc "C:\MyLoc\script3.sas";

等等

這種方法的缺點是您的程序將必須與以前運行時剩余的任何工作表/宏/宏變量等進行適當的處​​理(它們將沒有干凈的會話)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM