%syslput在rsubmit SAS

时间:2015-09-29 11:00:47

标签: macros sas remote-process

----------------------实现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;

2 个答案:

答案 0 :(得分:1)

使用%syslput语句时,您需要指定要将其定位到哪个远程会话,例如:

%syslput remote_var = value /remote=remote_session_name;

如果您没有指定会话,我认为SAS会尝试使用您上次远程提交的代码。但是因为您使用的是autosignon,所以您甚至在签署了由rsubmit生成的远程会话之前尝试执行%syslput

首先尝试登录会话,然后再使用%syslput同步宏变量,看看是否有帮助。 E.g。

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

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

答案 1 :(得分: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;