2015-09-29 30 views
1

----------------------實現使用rsubmit &訪問傳遞給它的值-------- --------------------%syslput在rsubmit中不起作用SAS

我想寫一個代碼,它將創建不同的遠程會話,也會傳遞數據集值到特定的rsubmit塊在宏的幫助下。我們知道簡單的宏變量值不能發送到rsubmit語句,因爲rsubmit會創建新的會話。這就是爲什麼我使用%syslput語句。但它不工作,請告訴我如何使用%syslput將數據集值傳遞給rsubmit語句。

options sascmd='!sascmd -nosyntaxcheck' autosignon=yes sysrputsync mprint symbolgen; 
    data data; 
    input [email protected]@; 
    datalines; 
    1 2 3 
    ; 
    run; 

    %macro startTask(n); 
     %syslput number=&n; 
     rsubmit Task&n wait=no; 
      %put Output from Task&number; 
      %put Value of Number:=&number; 
     endrsubmit; 
    %mend; 

    %macro finishTask; 
     waitfor _ALL_ Task1 Task2 Task3; 
     signoff Task1; 
     signoff Task2; 
     signoff Task3; 
    %mend; 

    data _NULL_; 
    set data end=last; 
    call execute('%nrstr(%startTask('||strip(num)||'))'); 
    run; 

    %finishTask 

登錄:------------->

1 options sascmd='!sascmd -nosyntaxcheck' autosignon=yes sysrputsync mprint symbolgen; 
2   data data; 
3   input [email protected]@; 
4   datalines; 

NOTE: SAS went to a new line when INPUT statement reached past the end of a line. 
NOTE: The data set WORK.DATA has 3 observations and 1 variables. 
NOTE: DATA statement used (Total process time): 
     real time   0.00 seconds 
     cpu time   0.00 seconds 


6   ; 
7   run; 
8 
9   %macro startTask(n); 
10    %syslput number=&n; 
11    rsubmit Task&n wait=no; 
12     %put Output from Task&number; 
13     %put Value of Number:=&number; 
14    endrsubmit; 
15   %mend; 
16 
17   %macro finishTask; 
18    waitfor _ALL_ Task1 Task2 Task3; 
19    signoff Task1; 
20    signoff Task2; 
21    signoff Task3; 
22   %mend; 
23 
24   data _NULL_; 
25   set data end=last; 
26   call execute('%nrstr(%startTask('||strip(num)||'))'); 
27   run; 

NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column). 
     26:50 
NOTE: There were 3 observations read from the data set WORK.DATA. 
NOTE: DATA statement used (Total process time): 
     real time   0.00 seconds 
     cpu time   0.00 seconds 


NOTE: CALL EXECUTE generated line. 
SYMBOLGEN: Macro variable N resolves to 1 
ERROR: Invalid or unspecified remote session ID. Set OPTIONS REMOTE=session_id. 
1 + %startTask(1) 
ERROR: Remote signon canceled. 
SYMBOLGEN: Macro variable N resolves to 1 
MPRINT(STARTTASK): rsubmit wait=no; 
NOTE: Remote signon to TASK1 commencing (SAS Release 9.02.02M2P090109). 
NOTE: Unable to open SASUSER.PROFILE. WORK.PROFILE will be opened instead. 
NOTE: All profile changes will be lost at the end of the session. 
NOTE: Copyright (c) 2002-2008 by SAS Institute Inc., Cary, NC, USA. 
NOTE: SAS (r) Proprietary Software 9.2 (TS2M2) 
     Licensed to REPORTING HOUSE, Site 70065340. 
NOTE: This session is executing on the NET_ASRV platform. 



NOTE: SAS initialization used: 
     real time   0.10 seconds 
     cpu time   0.07 seconds 

NOTE: Remote signon to TASK1 complete. 
NOTE: Background remote submit to TASK1 in progress. 
SYMBOLGEN: Macro variable N resolves to 2 
SYMBOLGEN: Macro variable N resolves to 2 
2 + %startTask(2) 
MPRINT(STARTTASK): rsubmit wait=no; 
NOTE: Remote signon to TASK2 commencing (SAS Release 9.02.02M2P090109). 
NOTE: Unable to open SASUSER.PROFILE. WORK.PROFILE will be opened instead. 
NOTE: All profile changes will be lost at the end of the session. 
NOTE: Copyright (c) 2002-2008 by SAS Institute Inc., Cary, NC, USA. 
NOTE: SAS (r) Proprietary Software 9.2 (TS2M2) 
     Licensed to REPORTING HOUSE, Site 70065340. 
NOTE: This session is executing on the NET_ASRV platform. 



NOTE: SAS initialization used: 
     real time   0.09 seconds 
     cpu time   0.03 seconds 

NOTE: Remote signon to TASK2 complete. 
NOTE: Background remote submit to TASK2 in progress. 
SYMBOLGEN: Macro variable N resolves to 3 
SYMBOLGEN: Macro variable N resolves to 3 
3 + %startTask(3) 
MPRINT(STARTTASK): rsubmit wait=no; 
NOTE: Remote signon to TASK3 commencing (SAS Release 9.02.02M2P090109). 
NOTE: Unable to open SASUSER.PROFILE. WORK.PROFILE will be opened instead. 
NOTE: All profile changes will be lost at the end of the session. 
NOTE: Copyright (c) 2002-2008 by SAS Institute Inc., Cary, NC, USA. 
NOTE: SAS (r) Proprietary Software 9.2 (TS2M2) 
     Licensed to REPORTING HOUSE, Site 70065340. 
NOTE: This session is executing on the NET_ASRV platform. 



NOTE: SAS initialization used: 
     real time   0.10 seconds 
     cpu time   0.06 seconds 

NOTE: Remote signon to TASK3 complete. 
NOTE: Background remote submit to TASK3 in progress. 
28 
29   %finishTask 
MPRINT(FINISHTASK): waitfor _ALL_ Task1 Task2 Task3; 
MPRINT(FINISHTASK): signoff; 
NOTE: Remote submit to TASK1 commencing. 
WARNING: Apparent symbolic reference NUMBER not resolved. 
Output from Task&number 
WARNING: Apparent symbolic reference NUMBER not resolved. 
Value of Number:=&number 
MPRINT(STARTTASK): endrsubmit; 
NOTE: Remote submit to TASK1 complete. 
NOTE: Remote signoff from TASK1 commencing. 
NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414 
NOTE: The SAS System used: 
     real time   0.46 seconds 
     cpu time   0.07 seconds 

NOTE: Remote signoff from TASK1 complete. 
MPRINT(FINISHTASK): signoff; 
NOTE: Remote submit to TASK2 commencing. 
WARNING: Apparent symbolic reference NUMBER not resolved. 
Output from Task&number 
WARNING: Apparent symbolic reference NUMBER not resolved. 
Value of Number:=&number 
MPRINT(STARTTASK): endrsubmit; 
NOTE: Remote submit to TASK2 complete. 
NOTE: Remote signoff from TASK2 commencing. 
NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414 
NOTE: The SAS System used: 
     real time   0.42 seconds 
     cpu time   0.03 seconds 

NOTE: Remote signoff from TASK2 complete. 
MPRINT(FINISHTASK): signoff; 
NOTE: Remote submit to TASK3 commencing. 
WARNING: Apparent symbolic reference NUMBER not resolved. 
Output from Task&number 
WARNING: Apparent symbolic reference NUMBER not resolved. 
Value of Number:=&number 
MPRINT(STARTTASK): endrsubmit; 
NOTE: Remote submit to TASK3 complete. 
NOTE: Remote signoff from TASK3 commencing. 
NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414 
NOTE: The SAS System used: 
     real time   0.37 seconds 
     cpu time   0.06 seconds 

NOTE: Remote signoff from TASK3 complete. 

更新宏代碼:

%macro startTask(n); 
signon Task&n; 
%syslput number=&n /remote=Task&n; 
rsubmit Task&n wait=no; 
%put Output from Task&number; 
%put Value of Number:=&number; 
endrsubmit; 
%mend; 

回答

1

當您使用%syslput聲明你需要指定您希望它定位的遠程會話,例如

%syslput remote_var = value /remote=remote_session_name; 

如果您沒有指定會話,我認爲SAS會嘗試使用您最後一次遠程提交的代碼。但是,因爲您使用的是autosignon,所以在您登錄rsubmit生成的遠程會話之前,您正在嘗試執行%syslput

在使用%syslput同步宏變量並查看是否有幫助之前,請先嚐試登錄到會話。例如。

%let number = 1; 
option autosignon = no; 
signon task1; 
%syslput number_remote = &number /remote = task1; 

這應該創建會話task1稱爲number_remote與價值1宏變量。

+0

%syslput number = 1/remote = Task1; \t \t \t%syslput number = 1/remote = Task2; \t \t \t%syslput number = 1/remote = Task3;這是用於指定sessionID的正確語法,如果是,我應該在哪裏添加這些語句? –

+0

請告訴我在哪裏應該把變量聲明代碼放在上面的程序中? –

+0

這是正確的代碼根據您的建議。 \t %syslput number = 1/remote = Task1; –