I am trying to pass local environment variables to a macro that is executed on a remote server using rsubmit. In the local environment I create the global var definitions, then call the macro %NITC_Remote; (the file is attached - and yes, I'm a novice). Thank you for your help.
EDITOR's NOTE: SERVER INFORMATION **REDACTED**
options mprint symbolgen mlogic
mautosource sasautos= ('H:\......\.....\Macros'); /*Location of Remote_macro*/
%macro gmacs;
%global molist yrlist sv;
%let mlist=03 06 09 12;
%let ylist=12 13 14 15 16 17;
%let sv=AS;
%mend gmacs;
%gmacs;
%NITC_Remote(&mlist,&ylist,&sv);
/*## MACRO CODE BEGINS HERE ##*/
%Macro NITC_Remote;
%let RTOT= H:/.../..../RTOT;
%syslput RTOT=&RTOT;
%let nitcspwn = **redacted**;
options comamid=tcp remote=**redacted** nosource ;
signon username=_prompt_ password=_prompt_ ; /*OPENS SIGN ON PROMPT*/
rsubmit;
%nrstr(%let molist=&mlist;)
%nrstr(%let yrlist=&ylist;)
%nrstr(%let sv=&sv;)
%macro regloop(yrlist, molist, sv);
%let s=1; %let t=1;
%let cntyr=%sysfunc(countw(&yrlist));
%let cntmo=%sysfunc(countw(&molist));
%do s=1 %to &cntyr;
%let yr=%scan(&yrlist,&s,%str( ));
%do t=1 %to &cntmo;
%let mo=%scan(&molist,&t,%str( ));
libname tots&yr.&mo. "NAP95&sv..&sv.US.D&yr.&mo.SUM.USRGN.SAS.DATA" disp=shr;
proc download data=tots&yr.&mo..rttots out=&RTOT.&sv._rttots&yr.&mo.;run;
%end;%end;
%mend;
%regloop(&yrlist, &molist, &sv);
endrsubmit;
signoff;
%Mend NITC_Remote;
You need to create the target libref on the local SAS session before running PROC DOWNLOAD on the remote session.
17 +proc download data=tots&yr.&mo..rttots out=RTOT.&sv._rttots&yr.&mo.;run; ... NOTE: Libref TOTS1203 was successfully assigned as follows: Engine: V9 Physical Name: NAP95AS.ASUS.D1203SUM.USRGN.SAS.DATA ERROR: Libname RTOT is not assigned. ERROR: Download function terminated.
So add a LIBNAME statement before the local macro call. Or if in the macro call then before the RSUBMIT/ENDRSUBMIT block.
libname RTOT "......";
Or if you meant to create a WORK dataset then remove the extra period from the OUT= value.
out=work.RTOT&sv._rttots&yr.&mo.
Hi,
Here is what listed in the SAS Online Help
"%SYSLPUT : Creates a new macro variable or modifies the value of an existing macro variable on a remote host or server.
To use %SYSLPUT, you must have initiated a link between a local SAS session or client and a remote SAS session or server using the SIGNON command or SIGNON statement. For more information, see the documentation for SAS/CONNECT software."
Basically, establish your connection first, via Signon statement, then from your local session, use %SYSLPUT to pass your global local macro variable(s) to the remote server.
Hope this helps,
Ahmed
AhmedAl_Attar, I have modified the macro language as follows. The Log file is attached. Still haveing trouble with the Libname statement. Thank you.
%Macro NITC_Remote;
%let RTOT= H:/...../...../...../RTOT;
%let nitcspwn = **redacted**;
options comamid=tcp remote=**redacted** nosource ;
signon username=_prompt_ password=_prompt_ ;
%syslput RTOT=&RTOT;
%syslput molist=&molist;
%syslput yrlist=&yrlist;
%syslput sv=&sv;
rsubmit;
%macro regloop(yrlist, molist, sv);
%let s=1; %let t=1;
%let cntyr=%sysfunc(countw(&yrlist));
%let cntmo=%sysfunc(countw(&molist));
%do s=1 %to &cntyr;
%let yr=%scan(&yrlist,&s,%str( ));
%do t=1 %to &cntmo;
%let mo=%scan(&molist,&t,%str( ));
libname tots&yr.&mo. "NAP95&sv..&sv.US.D&yr.&mo.SUM.USRGN.SAS.DATA" disp=shr;
proc download data=tots&yr.&mo..rttots out=RTOT.&sv._rttots&yr.&mo.;run;
%end;%end;
%mend;
%regloop(&yrlist, &molist, &sv);
endrsubmit;
signoff;
%Mend NITC_Remote;
Use %SYSLPUT. Change these lines
signon username=_prompt_ password=_prompt_ ;
rsubmit;
%nrstr(%let molist=&mlist;)
%nrstr(%let yrlist=&ylist;)
%nrstr(%let sv=&sv;)
...
To this instead.
signon username=_prompt_ password=_prompt_ ;
%syslput molist=&mlist;
%syslput yrlist=&ylist;
%syslput sv=&sv;
rsubmit;
...
If that has trouble because you are calling %SYSLPUT inside of a macro then you might want to revert to the method that SAS used before they made the %SYSLPUT statement. Here is a version of the %SYSLPUT() macro that they had back in SAS 6.12, renamed to avoid conflict with the new %SYSLPUT statement.
%macro syslput612(macvar,macval,remote=);
options nosource nonotes;
%let str=%str(rsubmit &remote;options nosource;)
%nrstr(%let) %str(&macvar = &macval;options source;endrsubmit;);
&str; options notes source;
%mend syslput612;
Code using macro.
signon username=_prompt_ password=_prompt_ ;
%syslput612(molist,&mlist)
%syslput612(yrlist,&ylist)
%syslput612(sv,&sv)
rsubmit;
...
Looks like the local macro is expanding some of the macro logic before pushing the generated macro definition to the remote session.
Can you take the remote macro defintion out of the local macro definition?
Or move it to the remote as text instead and then compile it?
EDITOR's NOTE: SERVER INFORMATION **REDACTED**
%macro NITC_Remote;
%let RTOT= H:/...../...../...../RTOT;
%let nitcspwn =**redacted**;
options comamid=tcp remote=nitcspwn nosource ;
signon username=_prompt_ password=_prompt_ ;
%syslput RTOT=&RTOT;
%syslput molist=&molist;
%syslput yrlist=&yrlist;
%syslput sv=&sv;
rsubmit;
filename code temp;
data _null_;
file code;
put
'%macro regloop(yrlist, molist, sv);'
/'%let s=1; %let t=1;'
/'%let cntyr=%sysfunc(countw(&yrlist));'
/'%let cntmo=%sysfunc(countw(&molist));'
/' '
/'%do s=1 %to &cntyr;'
/'%let yr=%scan(&yrlist,&s,%str( ));'
/'%do t=1 %to &cntmo;'
/'%let mo=%scan(&molist,&t,%str( ));'
/'libname tots&yr.&mo. "NAP95&sv..&sv.US.D&yr.&mo.SUM.USRGN.SAS.DATA" disp=shr;'
/'proc download data=tots&yr.&mo..rttots out=RTOT.&sv._rttots&yr.&mo.;run;'
/'%end;%end;'
/'%mend;'
;
run;
%include code / source2;
%regloop(&yrlist, &molist, &sv);
endrsubmit;
signoff;
%mend NITC_Remote;
Tom, I see there is still a problem with the libname assignment. At least now it is recognizing the file names (with distinct months) and file size at the remote location.
Attached is the log file.
...........
12 +%do s=1 %to &cntyr;
13 +%let yr=%scan(&yrlist,&s,%str( ));
14 +%do t=1 %to &cntmo;
15 +%let mo=%scan(&molist,&t,%str( ));
16 +libname tots&yr.&mo. "NAP95&sv..&sv.US.D&yr.&mo.SUM.USRGN.SAS.DATA" disp=shr;
17 +proc download data=tots&yr.&mo..rttots out=RTOT.&sv._rttots&yr.&mo.;run;
18 +%end;%end;
19 +%mend;
NOTE: %INCLUDE (level 1) ending.
20 %regloop(&yrlist, &molist, &sv);
NOTE: Libref TOTS1203 was successfully assigned as follows:
Engine: V9
Physical Name: NAP95AS.ASUS.D1203SUM.USRGN.SAS.DATA
ERROR: Libname RTOT is not assigned.
ERROR: Download function terminated. The data set created may be unusable.
NOTE: The data set TOTS1203.RTTOTS has 20181 observations and 40 variables.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: The PROCEDURE DOWNLOAD used 0.00 CPU seconds and 21901K.
NOTE: The address space has used a maximum of 980K below the line and 26192K above the line.
NOTE: Libref TOTS1206 was successfully assigned as follows:
Engine: V9
Physical Name: NAP95AS.ASUS.D1206SUM.USRGN.SAS.DATA
You need to create the target libref on the local SAS session before running PROC DOWNLOAD on the remote session.
17 +proc download data=tots&yr.&mo..rttots out=RTOT.&sv._rttots&yr.&mo.;run; ... NOTE: Libref TOTS1203 was successfully assigned as follows: Engine: V9 Physical Name: NAP95AS.ASUS.D1203SUM.USRGN.SAS.DATA ERROR: Libname RTOT is not assigned. ERROR: Download function terminated.
So add a LIBNAME statement before the local macro call. Or if in the macro call then before the RSUBMIT/ENDRSUBMIT block.
libname RTOT "......";
Or if you meant to create a WORK dataset then remove the extra period from the OUT= value.
out=work.RTOT&sv._rttots&yr.&mo.
Tom, That works... so, now I realize we have two solutions. In the beginning, %nrstr() should have been used on the %let, %do, %if.
EDITOR's NOTE: SERVER INFORMATION **REDACTED**
%let nitcspwn = **redacted**
;
options comamid=tcp remote=nitcspwn nosource ;
signon username=_prompt_ password=_prompt_ ;
%syslput molist=&molist;
%syslput yrlist=&yrlist;
%syslput sv=&sv;
rsubmit;
%macro regloop(yrlist, molist, sv);
%nrstr(%let s=1;) %nrstr(%let t=1;)
%nrstr(%let cntyr=%sysfunc(countw(&yrlist));)
%nrstr(%let cntmo=%sysfunc(countw(&molist));)
%nrstr(%do s=1 %to &cntyr;)
%nrstr(%let yr=%scan(&yrlist,&s,%str( ));)
%nrstr(%do t=1 %to &cntmo;)
%nrstr(%let mo=%scan(&molist,&t,%str( ));)
libname tots&yr.&mo. "NAP95&sv..&sv.US.D&yr.&mo.SUM.USRGN.SAS.DATA" disp=shr;
proc download data=tots&yr.&mo..rttots out=RTOT.&sv._rttots&yr.&mo.;run;
%end;%end;
%mend;
%regloop(&yrlist, &molist, &sv);
endrsubmit;
signoff;
%Mend NITC_Remote;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.