Desktop productivity for business analysts and programmers

How can i use macros from local machine to Remote machine in RSUBMIT Method

Reply
Contributor
Posts: 23

How can i use macros from local machine to Remote machine in RSUBMIT Method

I am using rsubmit method to run the Different programs parallel. I have macros at local machine, I must call macros across the remote servers (4 remove servers) without loading them in all remote servers. Same scenarios for filenames and formats usage across the remote servers which are available in local machine. 

 

How can i do the above effectively?

 

Super User
Posts: 20,203

Re: How can i use macros from local machine to Remote machine in RSUBMIT Method

Posted in reply to yanamadala85

I must call macros across the remote servers (4 remove servers) without loading them in all remote servers

 

 

What do you mean?

Super User
Super User
Posts: 7,144

Re: How can i use macros from local machine to Remote machine in RSUBMIT Method

Posted in reply to yanamadala85

After you start the remote session send it the code it needs to setup the environment you want it to have.

Might be good to place the code in a single place.

%include 'path_to_setup_code';
signon node1;
signon node2;
signon node3 ;
rsubmit node1 ;
%include 'path_to_setup_code';
endrsubmit;
rsubmit node2 ;
%include 'path_to_setup_code';
endrsubmit;
rsubmit node3 ;
%include 'path_to_setup_code';
endrsubmit;
Contributor
Posts: 23

Re: How can i use macros from local machine to Remote machine in RSUBMIT Method

below is the sample code i am using, I want to call the macro (%xyz) in all rsubmit blocks. Now i am getting the WARNING: Apparent invocation of macro XYZ not resolved error when i use in RSUBMIT blocks. how can i call the macro without write the macro in RSUBMIT blocks.

 

 

%let rc = %sysfunc( grdsvc_enable(_all_, server= SASApp_DEV));
/*signon grid1;*/
/*signon grid2;*/
options autosignon;
filename testlib "C:\Users\yanamadalavenkatesh\Desktop\SAS Parallel Execution\Rsubmit";
libname shared "%sysfunc(pathname(testlib))";
filename logfil "C:\Users\yanamadalavenkatesh\Desktop\SAS Parallel Execution\Rsubmit\ab.log" mod;
filename logfil1 "C:\Users\yanamadalavenkatesh\Desktop\SAS Parallel Execution\Rsubmit\cd.log" mod;
filename logfil2 "C:\Users\yanamadalavenkatesh\Desktop\SAS Parallel Execution\Rsubmit\ef.log" mod;
%macro xyz;
data shared.ABC;
do i= 1 to 100000;
update =rand('Uniform');
end;
run;
%mend xyz;
rsubmit grid1 wait=no inheritlib=(shared) /*NOTIFY=YES*/ log=logfil;

data shared.AB;
do i= 1 to 100000;
update =rand('Uniform');
end;
run;
%xyz;
%put &syshostname;
endrsubmit;
rsubmit grid2 wait=no inheritlib=(shared) log=logfil1 ;

data shared.CD;
do i= 1 to 100000;
update =rand('Uniform');
end;
run;
%put &syshostname;
endrsubmit;

rsubmit grid3 wait=no inheritlib=(shared) log=logfil2 ;

data shared.EF;
do i= 1 to 100000;
update =rand('Uniform');
end;
run;
%put &syshostname;
endrsubmit;

Super User
Super User
Posts: 7,144

Re: How can i use macros from local machine to Remote machine in RSUBMIT Method

Posted in reply to yanamadala85

You have to do something in the remote session so that it can find the macro definition. So either explicitly have it compile the macro or put the macro definition in an autocall location and have the remote session use autocall functionality to define the macro.

 

It might be possible to compile the macro into a macro store catalog in the SHARED library and tell the remote session to search that compiled macro catalog for macros.  But I find that even more complex than just giving it the code.

Super User
Posts: 20,203

Re: How can i use macros from local machine to Remote machine in RSUBMIT Method

Posted in reply to yanamadala85

how can i call the macro without write the macro in RSUBMIT blocks

 

 

You can't. You need to have the macro defined somewhat on the machine otherwise how does it know what code to run?

You could build a different macro that had an RSUBMIT within the macro but that would be a different issue. This is clearly either demo code so it may help if you explain some more what you're trying to do here besides being an training exercise. 

Contributor
Posts: 23

Re: How can i use macros from local machine to Remote machine in RSUBMIT Method

I have mstored compiled macro catalogs in the location "\\C:shared".

each macro do different functionality (like, ISO date conversion, formats creation, some calcuctions etc.)

 

I have some 20 programs available in another location "\\CSmiley Tonguerograms".

 

Now i need to write a macro which can run programs (available in "\\CSmiley Tonguerograms"). some times i have to use macro catalogs which are available in  "\\C:shared" location (means, need to call those macros in rsubmit blocks).

 

Example code:

%let rc = %sysfunc( grdsvc_enable(_all_, server= SASApp_DEV));
options autosignon;
filename testlib "C:\Users\yanamadalavenkatesh\Desktop\SAS Parallel Execution\Rsubmit";
libname shared "%sysfunc(pathname(testlib))";

rsubmit grid1 wait=no inheritlib=(shared) /*NOTIFY=YES*/ log=logfil;

%formatds;  **Catalog is available in  \\C:shared location;

%include "\\CSmiley Tonguerograms\dm.sas";
endrsubmit;

 

rsubmit grid2 wait=no inheritlib=(shared) /*NOTIFY=YES*/ log=logfil;

%isodt;  **Catalog is available in  \\C:shared location;

%include "\\CSmiley Tonguerograms\lb.sas";
endrsubmit;

 

My question is, how can I use those catalogs (Means, How can i call those macros) in RSUBMIT blocks. Can you provide the sample code for the same.

Respected Advisor
Posts: 4,185

Re: How can i use macros from local machine to Remote machine in RSUBMIT Method

Posted in reply to yanamadala85

@yanamadala85

Your locally compiled macros are available to your local SAS session but NOT to your remote GRID environment. 

You need to compile the macros in your GRID environment (as code during run-time directly in your rsubmit blocks, store the macro code in a folder defined as part of the SAS AUTOCALL facility (Grid server side) or compile it on the Grid into a Macro catalog which is part of the SASAUTOS search path).

 

In case there is a folder location accessible from both your local environment and your Grid environment (unlikely but possible) then you can maintain a single code source else you will have to replicate your macro code.

 

Super User
Posts: 20,203

Re: How can i use macros from local machine to Remote machine in RSUBMIT Method

Posted in reply to yanamadala85

yanamadala85 wrote:

 

 

My question is, how can I use those catalogs (Means, How can i call those macros) in RSUBMIT blocks. Can you provide the sample code for the same.


Running a code on a server/grid/batch means that it sees NOTHING on your computer unless you explicitly specify it. It's literally a different computer and can't see the catalog UNLESS you somehow make that accessible to your server/grid.

Super User
Super User
Posts: 7,144

Re: How can i use macros from local machine to Remote machine in RSUBMIT Method

Posted in reply to yanamadala85

yanamadala85 wrote:

I have mstored compiled macro catalogs in the location "\\C:shared".

each macro do different functionality (like, ISO date conversion, formats creation, some calcuctions etc.)

... 

 

Sounds like you already know how to access stored macro catalogs. Just do the same thing in each of the remote sessions.

Contributor
Posts: 23

Re: How can i use macros from local machine to Remote machine in RSUBMIT Method

Thanks to all. that is true. I shall try the same.

 

 I have another question, How can I access work libraries across the grids and local machine, without defining the same location for all servers work libraries?.

 

1. Local work library in Remote machine.

2. Remote work library in Local machine

3. One Remote work library in another remote machine

Ask a Question
Discussion stats
  • 10 replies
  • 167 views
  • 2 likes
  • 4 in conversation