DATA Step, Macro, Functions and more

remote macro variables in local code

Reply
Occasional Contributor
Posts: 7

remote macro variables in local code

hi, so i have been struggling with this for a little while.

i have a sas file that has a bunch of macros in it, which i would like to execute on a remote server. portions of those need to execute on my local pc sas (mainly proc exports).

so for example:

%include 'some file';

%macro1(var1,var2,var3);

what i need is to include var1 within a macro that is executed both remotely and locally. i have been trying to get %syslput and %sysrput to work for me, but its just not happening.

any help would be greatly appreciated.

PROC Star
Posts: 7,356

Re: remote macro variables in local code

I'm not suggesting that this paper has your answer, but it might: http://www2.sas.com/proceedings/sugi30/224-30.pdf

Regardless, it is worth the short time it will take to read it.

Super Contributor
Posts: 644

Re: remote macro variables in local code

Have you tried running SAS Connect in "reverse"?  That is where the server becomes the client for a remote session on what you currently regard as your local machine.  You would then have 2 sessions on your PC and could control the exports by nesting rsubmits:

Local1 => rsubmit to server running main extract and analysis => rsubmit and upload to Local2 for export

Just a thought

Richard in Oz

Contributor
Posts: 29

Re: remote macro variables in local code

I've struggled with this too.

Going from my Windows client to my AIX server a simple:

  %syslput msg1=&msg1.;

   rsubmit;

   ...

   endrsubmit;

works to define the variable msg1 in the remote session.

However, coming back the other way I find it does not work unless I do this:

    rsubmit;

    %nrstr(%sysrput rmtuser=&sysuserid);

    endrsubmit;

I don't know why that %nrstr makes a difference, but it seems to!

Occasional Contributor
Posts: 7

Re: remote macro variables in local code

Ok, so I think that I at least understand the premise of what is going on... a follow up question though.

in my 'macro' file, i have sever proc exports... i would like to execute everything on the server with the exception of the proc export itself, so this would need to be executed locally.

so basically the file would like something like

%macro test(variables);

some sas code;

proc export;

some more sas code;

%mend test;

i tried to do this:

%macro test(variables);

some sas code;

endrsubmit;

proc export;

rsubmit remote=server;

some more sas code;

%mend test;

but that does't seem to be working

Super User
Super User
Posts: 6,498

Re: remote macro variables in local code

Why not run the macro on the LOCAL machine?  Then your macro definition becomes:

%macro test(variables);

rsubmit;

   some sas code;

    Perhaps a PROC DOWNLOAD.

endrsubmit;

proc export;

...

rsubmit;

    Perhaps a PROC UPLOAD.

   some more sas code;

endrsubmit;

%mend test;

Occasional Contributor
Posts: 7

Re: remote macro variables in local code

That's essentially what I am doing... however, the macro is located in another file.

so i %include the macro(s) file and then call the macros from the other program.

so my macro (in the external file) would look something like this:

%macro test;

rsubmit server="server";

data make_ds;

set ds2;

run;

endrsubmit;

%mend test;

this then throws an error:

connection to "server" does not exist. you must establish  a connection by issuing the signon with the server=option or setting the global autosignon option.

remote submit to "server" canceled.

and then sas hangs with "remote processing in progress"

so i tried to add the signon="sever" option to the macro, which presented me with a window to fill out some credentials, and eventually told me that the SAS/CONNECT Server name should be a quoted string.

Ask a Question
Discussion stats
  • 6 replies
  • 686 views
  • 3 likes
  • 5 in conversation