Here is my macro in SAS 9.3:
%LET GERC=%SYSFUNC( GrdSvc_Enable(_all_,resource=&SASAppSvr.));
%PUT GERC=&GERC.;
OPTIONS noSYMBOLGEN signonwait noMPRINT noMLOGIC NOTES COMPRESS=NO NOFULLSTIMER NOERRORABEND noMFILE;
LIBNAME dissert "*\DATA\";
%MACRO gridsubmit;
%LET tnum=1;
PROC PRINTTO LOG="*\LOGS\grid_enable.log" NEW;
RUN;
%DO start=1 %TO 981 %BY 20;
SIGNON task&tnum;
%SYSLPUT start=&start;
%SYSLPUT tnum=&tnum;
RSUBMIT task&tnum WAIT=NO PERSIST=NO;
%PUT Session started on grid node %sysfunc( grdsvc_getname( task&tnum));
OPTIONS noSYMBOLGEN noMPRINT noMLOGIC noNOTES COMPRESS=NO NOFULLSTIMER noERRORABEND noMFILE;
LIBNAME dissert "*\DATA\";
LIBNAME simulate "*\DATA\simulated\";
%INCLUDE "*\mod_defs ND v21.sas";
%INCLUDE "*\optimization ND v21.sas";
%INCLUDE "*\M_step ND v17.sas";
%INCLUDE "*\macro simulation wl v2.sas";
%INCLUDE "*\hazard.sas";
%simulations (
numsims=20,
startwhere=&start,
results=dissert.output&tnum,
K=3,
P=2,
dset1=simulate.testlong,
dset2=simulate.testwide,
num_nodes=12,
convcrit=1E-4,
varcrit=1E-15,
shft=1,
limit=4500,
limit2=200,
non=1 1 1,
sg=1)
ENDRSUBMIT;
%LET tnum=%EVAL(&tnum+1);
%END;
WAITFOR _ALL_ %DO tnum=1 %TO 50; task&tnum %END; ;
SIGNOFF _ALL_;
data dissert.output;
set %DO tnum=1 %TO 50; dissert.output&tnum %END;;
run;
%MEND gridsubmit;
%gridsubmit;
%*LET num=%sysfunc(grdsvc_nnodes(server=&SASAppSvr)); %PUT #
%*LET rc=%sysfunc(grdsvc_getinfo(_ALL_)); %PUT &rc;
After running I get connection to the first task then every task thereafter I get the same warning:
NOTE: Remote signon to TASK1 complete.
NOTE: Background remote submit to TASK1 in progress.
NOTE: Remote submit to TASK1 commencing.
Session started on grid node *
ERROR: A link to TASK2 does not exist; execute SIGNON to establish the link.
Session started on grid node
WARNING: The value for variable START has been overridden due to interleaving SYSLPUT with
asynchronous remote processing.
WARNING: The value for variable TNUM has been overridden due to interleaving SYSLPUT with
asynchronous remote processing.
Skipping the rsubmit macro entirely, writing another macro with PUT statements to write the entire program with 50 rsubmits to another file. Problem solved.
Try telling it which session to put the variables into.
SIGNON task&tnum;
%SYSLPUT start=&start /remote=task&tnum;
%SYSLPUT tnum=&tnum /remote=task&tnum;
that solved the warning but not the error.
ERROR: A link must be established by executing the SIGNON command before you can communicate with
TASK2.
ERROR: A link must be established by executing the SIGNON command before you can communicate with
TASK2.
ERROR: A link to TASK2 does not exist; execute SIGNON to establish the link.
Session started on grid node
ERROR: A link must be established by executing the SIGNON command before you can communicate with
TASK3.
ERROR: A link must be established by executing the SIGNON command before you can communicate with
TASK3.
Sounds like your SIGNON is not finishing before your %SYSLPUT is running?
Another thing that I have had to use is to revert to using the old SAS 6.12 style macro for pushing macro values into the remote session.
Here is a %MSYSLPUT() macro to do that.
%macro msyslput
/*----------------------------------------------------------------------
Send value to remote macro variable while running inside a local macro
----------------------------------------------------------------------*/
(macvar /* Name of remote macro variable to set */
,macval /* Value to assign to remote macro variable */
,remote /* (Optional) Name of remote session to send to */
);
/*----------------------------------------------------------------------
When trying to set remote macro variables within a local macro execution
SAS can get confused with timing and execution. Reverting to using this
older method fixes that issue.
Based on SAS 6.12 autocall macro SYSLPUT that existed before SAS added
the %SYSLPUT macro statement.
----------------------------------------------------------------------*/
%local str ;
%let str=%str(rsubmit &remote;)%nrstr(%let) %str(&macvar = &macval;endrsubmit;);
&str.
%mend msyslput;
What happens if you use the REMOTE = option on SYSLPUT as explained here:
http://support.sas.com/kb/40/924.html
Perhaps related to "asynchronous" remote session management.
And possibly not.
I think you'll solve the problem by removing the SIGNON into a preliminary loop.
Afterthought addeded by: Peter
The SIGNON loop worked for the connection.
The /REMOTE option appeared to work but now the macro variables do not resolve so the RSUBMIT goes nowhere
You will need to stop using %SYSLPUT statement and use the old %NRSTR() trick, either via a utility macro or just using you ow local macro variable.
See this thread from last year.
did you include the syslput statements in the signon loop?
If so, you might need to add also a synchronous connect rsub to ensure that the macro values have landed
no they are not in the loop. I used the remote=option. Now that you mention it, there is not /remote option for %SYSLPUT in 9.2.....
Sorry about the confusion, the remote server I'm using is 9.2 not 9.3. Using lots of servers and different versions, got mixed up.
Here is my current program. Looks like the first RSUBMIT works fine but after that I get:
2940 RSUBMIT task&loop WAIT=NO PERSIST=NO;
ERROR: Unrecognized option, &.
ERROR: Remote submit canceled.
%MACRO gridsubmit;
%DO loop=1 %TO 41 %BY 20;
SIGNON task&loop SIGNONWAIT=Y;
%SYSLPUT start=&loop;
%END;
%DO loop=1 %TO 41 %BY 20;
RSUBMIT task&loop WAIT=NO PERSIST=NO;
%NRSTR(%%)PUT Session started on grid node %sysfunc( grdsvc_getname( task&start));
OPTIONS noSYMBOLGEN noMPRINT noMLOGIC noNOTES COMPRESS=NO NOFULLSTIMER noERRORABEND noMFILE;
LIBNAME dissert "\\\DATA\";
LIBNAME simulate "\\\DATA\simulated\";
%INCLUDE "\\\mod_defs ND v21.sas";
%INCLUDE "\\\optimization ND v21.sas";
%INCLUDE "\\\M_step ND v17.sas";
%INCLUDE "\\\macro simulation wl v2.sas";
%INCLUDE "\\\hazard.sas";
%simulations (
numsims=1,
startwhere=&start,
results=dissert.output&start,
K=3,
P=2,
dset1=simulate.testlong,
dset2=simulate.testwide,
num_nodes=12,
convcrit=1E-4,
varcrit=1E-15,
shft=1,
limit=4500,
limit2=200,
non=1 1 1,
sg=1)
ENDRSUBMIT;
%END;
WAITFOR _ALL_ %DO start=1 %TO 41 %BY 20; task&start %END; ;
SIGNOFF _ALL_;
data dissert.output;
set %DO start=1 %TO 41 %BY 20; dissert.output&start %END; ;
run;
%MEND gridsubmit;
Only the first Rsubmit runs. Looks like I need to abandon this macro and explicitly call the 50 RSUBMITS. Any suggestions on how to automate this process?
2940 RSUBMIT task&loop WAIT=NO PERSIST=NO;
ERROR: Unrecognized option, &.
This looks like a parser mistake. Either create another macro variable to contain the value of the task name.
%let task=task&loop;
rsubmit &task ... ;
Or use %UNQUOTE()
rsubmit %unquote(task&loop) ....
Skipping the rsubmit macro entirely, writing another macro with PUT statements to write the entire program with 50 rsubmits to another file. Problem solved.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.