1

----------------------实现使用 rsubmit 并访问传递给它的值----------------- ----------

我正在尝试编写一个代码来创建不同的远程会话,它还将在宏的帮助下将数据集值传递给特定的 rsubmit 块。我们知道简单的宏变量值不能发送到 rsubmit 语句,因为 rsubmit 会创建新会话。这就是我使用 %syslput 语句的原因。但它不起作用,请告诉我如何使用 %syslput 将数据集值传递给 rsubmit 语句。

    options sascmd='!sascmd -nosyntaxcheck'  autosignon=yes sysrputsync mprint symbolgen;
    data data;
    input num@@;
    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 num@@;
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;
4

2 回答 2

1

当您使用%syslput语句时,您需要指定您希望它定位的远程会话,例如

%syslput remote_var = value /remote=remote_session_name;

如果您不指定会话,我认为 SAS 会尝试使用您上次远程提交代码的会话。但是因为您正在使用,所以您甚至在登录到由 rsubmit 生成的远程会话之前autosignon就尝试执行您的操作。%syslput

在使用 %syslput 同步宏变量之前先尝试登录会话,看看是否有帮助。例如

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

这应该创建一个number_remote在会话task1中调用的宏变量,其值为1

于 2015-09-29T12:18:13.797 回答
0

如果您想使用远程宏变量,您的宏变量需要在 rsubmit 的宏中。如果您将所有内容都包装在一个宏中,那就更容易了。尝试这个:

%macro startTask(n); 
signon Task&n; 
%syslput number=&n /remote=Task&n;
rsubmit Task&n wait=no; 
%macro test();
%put Output from Task&number; 
%put Value of Number:=&number; 
%mend test;
%test;
endrsubmit; 
%mend;
于 2019-04-11T09:23:10.567 回答