DATA Step, Macro, Functions and more

sas macros

Reply
Contributor
Posts: 41

sas macros

I'm trying to run the following piece of code:

 

%let abc_unix = &sd_exports.;

%sysrput abc_unix = &abc_unix.;

LIBNAME abc "&abc_unix.";

 

I get the error " %SYSRPUT statement is valid only when OPTION DMR is in effect.".

 

What should I be adding to get this to run successfully?

Super User
Posts: 23,662

Re: sas macros

Posted in reply to astha8882000

DMR option is not set, which means it's: 

 

NODMR

disables you from invoking a remote SAS session.

 

If it's set this way, you can't push your macro variable to the remote session, because you can't connect to it.

 

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000279080.htm

 


@astha8882000 wrote:

I'm trying to run the following piece of code:

 

%let abc_unix = &sd_exports.;

%sysrput abc_unix = &abc_unix.;

LIBNAME abc "&abc_unix.";

 

I get the error " %SYSRPUT statement is valid only when OPTION DMR is in effect.".

 

What should I be adding to get this to run successfully?


 

 

 

Contributor
Posts: 41

Re: sas macros

Got it, thanks. What can I add to make that work?

 

Contributor
Posts: 41

Re: sas macros

Posted in reply to astha8882000

I tried doing this:

 

%let abc_unix = &sd_exports.;
%nrstr(%sysrput abc_unix = &abc_unix.);

LIBNAME abc "&abc_unix.";

 

that gave me the error: Statement is not valid or it is used out of proper order.

 

Then I did this: 

%let abc_unix = &sd_exports.;
%nrstr(%%)sysrput abc_unix = &abc_unix.;

LIBNAME abc "&abc_unix.";

 

that gave me this error: LINE and COLUMN cannot be determined.
NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.
ERROR 180-322: Statement is not valid or it is used out of proper order.

Contributor
Posts: 41

Re: sas macros

Posted in reply to astha8882000
I tried doing that too, that didn't help either:

%let abc_unix = &sd_exports.
rsubmit;
%sysrput abc_unix = &abc_unix.;
endrsubmit;
LIBNAME abc "&abc_unix.";

I get the following error: ERROR: The text expression &abc_UNIX. contains a recursive reference to the macro variable abc_UNIX. The macro variable will be assigned the null value.
Super User
Posts: 23,662

Re: sas macros

Posted in reply to astha8882000

Do you want SYSLPUT instead of RPUT?

 

RPUT moves macro variables from the Remote server to local. 

LPUT moves macro variables from the Local to the server. 

 

 

Contributor
Posts: 41

Re: sas macros

It's definitely rput because I need to read a dataset from that remote server.
Super User
Super User
Posts: 8,069

Re: sas macros

[ Edited ]
Posted in reply to astha8882000

@astha8882000 wrote:
I tried doing that too, that didn't help either:
%let abc_unix = &sd_exports.
rsubmit;
%sysrput abc_unix = &abc_unix.;
endrsubmit;
LIBNAME abc "&abc_unix.";






I get the following error: ERROR: The text expression &abc_UNIX. contains a recursive reference to the macro variable abc_UNIX. The macro variable will be assigned the null value.

Your first line sets the local macro variable ABC_UNIX to the value of the macro variable SD_EXPORTS.  Assuming that you actually ended the %LET statement with a semi-colon.

Your next three lines form a remote submit block that is attempting to recursively define a macro variable ABC_UNIX in the remote session.  It has nothing to do with the other lines at all.

So effectively you ran these two lines.

%let abc_unix = &sd_exports. ;
LIBNAME abc "&abc_unix.";

 What is it that you actual WANT to do?

Perhaps something like this?

rsignon;
%syslput abc_unix = &sd_exports.;
rsubmit;
LIBNAME abc "&abc_unix.";
endrsubmit;

Or something else?

Contributor
Posts: 41

Re: sas macros

So this was my original code and mentioned with the code lines is what my aim was:

%let abc_unix = &sd_exports.; //this is the target folder

%sysrput abc_unix = &abc_unix.;--this will start reading from server into the target folder

LIBNAME abc "&abc_unix."; this will create a libref to that target folder
Super User
Posts: 23,662

Re: sas macros

Posted in reply to astha8882000

%sysrput abc_unix = &abc_unix.;--this will start reading from server into the target folder

 

No, it will create a macro variable with that value on the remote server. Nothing is moved or read, you only create a macro variable. 

 

 

Super User
Super User
Posts: 8,069

Re: sas macros

Posted in reply to astha8882000

@astha8882000 wrote:

I'm trying to run the following piece of code:

 

%let abc_unix = &sd_exports.;

%sysrput abc_unix = &abc_unix.;

LIBNAME abc "&abc_unix.";

 

I get the error " %SYSRPUT statement is valid only when OPTION DMR is in effect.".

 

What should I be adding to get this to run successfully?


%SYSRPUT runs on the REMOTE session. 

That code would make more sense it you included the first two lines in an RSUBMIT block.

rsubmit;
  %let abc_unix = &sd_exports.;
  %sysrput abc_unix = &abc_unix.;
endrsubmit;

LIBNAME abc "&abc_unix.";
Contributor
Posts: 41

Re: sas macros

I tried that, it gave me the following error:

ERROR: Invalid or unspecified remote session ID. Set OPTIONS REMOTE=session_id.
NOTE: Subsequent lines will be ignored until ENDRSUBMIT.
ERROR: Remote submit to UNKNOWN canceled.
Super User
Super User
Posts: 8,069

Re: sas macros

Posted in reply to astha8882000

If you don't have a remote session running you cannot do ANYTHING on the non-existent remote session.

 

How are you creating the remote session?  Normally I would use signon command to start a remote session.  I would know the NAME of the remote session.  What is the name of the remote session you are trying to reference?

 

You can create a local libref that points to remote location without creating any macro variables on the remote session.

libname mylib remote "path on remote" server=remotname ;
Super User
Posts: 3,909

Re: sas macros

Posted in reply to astha8882000

This code worked fine for me (you may need to add SIGNON options):

 

signon;

rsubmit;

  %let abc_unix = Just Testing;
  %sysrput abc_unix = &abc_unix.;

endrsubmit;

%put abc_unix = &abc_unix.; 
Contributor
Posts: 41

Re: sas macros

I tried this and got the error:

ERROR: Invalid or unspecified remote session ID. Set OPTIONS REMOTE=session_id.
ERROR: Remote signon to UNKNOWN canceled.
25
26 rsubmit;
ERROR: Invalid or unspecified remote session ID. Set OPTIONS REMOTE=session_id.
NOTE: Subsequent lines will be ignored until ENDRSUBMIT.
ERROR: Remote submit to UNKNOWN canceled.
Ask a Question
Discussion stats
  • 16 replies
  • 115 views
  • 0 likes
  • 5 in conversation