1

----------------------Implementing use of rsubmit & accessing values passed to it----------------------------

I am trying to write a code which will create different remote session, also it'll pass data set values to particular rsubmit blocks with the help of macros. We know that simple macro variable values cannot be sent to rsubmit statements because rsubmit creates new session. Thats why I used %syslput statement. But its not working, please tell me how can I pass data set values to the rsubmit statements using %syslput.

    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

Log:------------->

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.

Updated macro code:

%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;
user667489
  • 9,501
  • 2
  • 24
  • 35
mac_21
  • 113
  • 9

2 Answers2

1

When you use a %syslput statement you need to specify which remote session you want it to target, e.g.

%syslput remote_var = value /remote=remote_session_name;

If you don't specify a session, I think SAS tries to use the one you last remote submitted code to. But because you are using autosignon, you are trying to do your %syslput before you've even signed on to the remote sessions generated by the rsubmit.

Try signing onto your sessions first before using %syslput to synchronise your macro variables and see if that helps. E.g.

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

That should create a macro variable called number_remote in the session task1 with the value 1.

user667489
  • 9,501
  • 2
  • 24
  • 35
  • %syslput number=1 / remote=Task1; %syslput number=1 / remote=Task2; %syslput number=1 / remote=Task3; Is this right syntax for specifying sessionID, If yes, where should I add these statements? – mac_21 Sep 29 '15 at 13:55
  • Please tell me where should I put the variable declaration code in above program? – mac_21 Sep 29 '15 at 14:08
  • Is this correct code as per your suggestion. %syslput number=1 / remote=Task1; – mac_21 Sep 29 '15 at 14:09
  • I've added an example. – user667489 Sep 29 '15 at 21:13
  • Code corrected - I had some of the syntax backwards. – user667489 Sep 30 '15 at 11:39
  • I set option to autosignon=no as you said & made signon option for each task but its still giving WARNING: Apparent symbolic reference NUMBER not resolved. I have made the following changes in my code, cahnges--> options sascmd='!sascmd -nosyntaxcheck' autosignon=no mprint symbolgen; %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; please you try the code – mac_21 Oct 01 '15 at 05:12
  • Do you get the same error if you call the macro directly rather than via call execute? – user667489 Oct 01 '15 at 07:33
0

Your macro variable needs to be within a macro in the rsubmit if you wanna use the remote macro variable. It's easier if you just wrap everything in a macro. Try this:

%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;