BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jakestat
Obsidian | Level 7

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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.

View solution in original post

9 REPLIES 9
AhmedAl_Attar
Rhodochrosite | Level 12

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

jakestat
Obsidian | Level 7

 

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;

Tom
Super User Tom
Super User

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;
...
jakestat
Obsidian | Level 7
Tom, after I modified based on your first option (also suggested by Ahmed), that part of it worked (i think). Not there is a libname that does not assign. (see log attached).
Tom
Super User Tom
Super User

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;

 

jakestat
Obsidian | Level 7


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

 

Tom
Super User Tom
Super User

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.
jakestat
Obsidian | Level 7

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;

jakestat
Obsidian | Level 7
The second solution was not* using %syslput with %let for the libname. As you said, just put the libname as usual before the connect prompt.

%Macro NITC_Test3; /*Jacob Carter*/

libname RTOT "H:\Shared\MDSEIMB\SFDS\SDS\Green Book\RTOT";

%let nitcspwn = 165.xxx.4.xx xxxx;
options comamid=tcp remote=nitcspwn nosource ;
signon username=_prompt_ password=_prompt_ ;

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 9 replies
  • 5552 views
  • 1 like
  • 3 in conversation