Call local SAS macro in RSUBMIT block?

I have a macro that I created on my local machine in a .sas file. I also have a local dataset that was used to validate the macro. This dataset has the same descriptors as the remote dataset, but only fewer observations. Now I am trying to run a local macro with a remote dataset. Here is basically what I have:

This works as expected:

%include "C:\my_sas_macro.sas";

%my_sas_macro(my_data=work.localdata)

but then generates an error (error follows):

%include "C:\my_sas_macro.sas";

rsubmit;
%my_sas_macro(my_data=remotelib.remotedata)
endrsubmit;

Error log:

125  %include "C:\my_sas_macro.sas";
136
137  rsubmit;
NOTE: Remote submit to REMOTEID.__7551 commencing.
WARNING: Apparent invocation of macro MY_SAS_MACRO not resolved.
83   %my_sas_macro(my_data=remotelib.remotedata)
     -
     180
ERROR 180-322: Statement is not valid or it is used out of proper order.
84   endrsubmit;

NOTE: Remote submit to REMOTEID.__7551 complete.

I am sure that I need to somehow transfer the% macro /% mend block to the server, but I cannot figure out how to do this. I saw %SYSLPUT, but for macro variables and not for full macros.

, SSH %include ?

!

[]

, @CarolinaJay65, , .

%macro include_on_server(file=);
%let server_file = ~/temp.sas;
%SYSLPUT macro_file=&file;
%SYSLPUT server_file = &server_file;

rsubmit;

proc upload
    infile= "&macro_file."
    outfile= "&server_file."
; run;

%include "&server_file.";
endrsubmit;

%mend include_on_server;

%include_on_server(file="C:\my_file.sas"), .

+5
3

Proc

 rsubmit;
 Proc Upload
  infile='C:\my_sas_macro.sas'
  outfile='//server/my_sas_macro.sas' ;
 run;

 %include '//server/my_sas_macro.sas';
 %my_sas_macro(my_data=remotelib.remotedata)

, % syslput

+6

, CarolinaJay. , , LIBNAME :

libname server = slibref =; libname myserver server = unix slibref = work;

'unix' script .

, , , PROC COPY, libref, , , . (SASMACR), libref ( ). , . , , , , .

, : http://www.nesug.org/proceedings/nesug05/io/io2.pdf PROC UPLOAD , .

+1

Place rsubmit / endrsubmit inside the include, around the macro definition. When you include a local file, it will delete the macro remotely.

EDIT:

i.e.

c: \ remote_macro.sas contains the following:

rsubmit ;
  %MACRO MYMACRO ;
    /* do stuff */
  %MEND ;

  %MACRO ANOTHERMACRO(PARAM) ;
    /* Do other things */
    %PUT &PARAM ;
  %MEND ;
endrsubmit ;

Then run the following in SAS:

%inc "c:\remote_macro.sas" ;

rsubmit ;
  %MYMACRO ;
  %ANOTHERMACRO(Hello World) ;
endrsubmit ;
+1
source

All Articles