BookmarkSubscribeRSS Feed
SAS_user
Calcite | Level 5
Hello i have a problem about with SAS connect when using %sysrput statement.
When i submit a code i work, but when i submit my code from macro it fails to work.

Here is the code:

dm log "clear";
options nosource nomprint;

%let SASMain = xx.xx.xxx.xx xxxx;
signon SASMain noscript user="***" password="********";

rsubmit sasmain MACVAR=SIGNONRETURNCODE;

options nosource;
%let error = 0;

data aaa;
set sashelp.class;
run;

%sysrput RemoteError = &error;

endrsubmit;
%put #### &RemoteError ####;

signoff;

%macro fromMacro;

%let SASMain = xx.xx.xxx.xx xxxx;
signon SASMain noscript user="***" password="********";

rsubmit sasmain MACVAR=SIGNONRETURNCODE;
options nosource;

%let error = 0;

data aaa;
set sashelp.class;
run;

%sysrput RemoteErrorFromMacro = &error;

endrsubmit;
%put #### &RemoteErrorFromMacro ####;

%mend fromMacro;
%fromMacro;
signoff;


Here is the log:

NOTE: Remote signon to SASMAIN commencing (SAS Release 9.01.01M3P020206).
NOTE: Copyright (c) 2002-2003 by SAS Institute Inc., Cary, NC, USA.
NOTE: SAS (r) 9.1 (TS1M3)
Licensed to OMNITEL, Site 0088197007.
NOTE: This session is executing on the HP-UX B.11.23 platform.

NOTE: Running on HP Model ia64 Serial Number 4075303309.


NOTE: SAS 9.1.3 Service Pack 4

You are running SAS 9. Some SAS 8 files will be automatically converted
by the V9 engine; others are incompatible. Please see
http://support.sas.com/rnd/migration/planning/platform/64bit.html

PROC MIGRATE will preserve current SAS file attributes and is
recommended for converting all your SAS libraries from any
SAS 8 release to SAS 9. For details and examples, please see
http://support.sas.com/rnd/migration/index.html


This message is contained in the SAS news file, and is presented upon
initialization. Edit the file "news" in the "misc/base" directory to
display site-specific news and information in the program log.
The command line option "-nonews" will prevent this display.




NOTE: The paths specified with the UTILLOC option do not exist. UTILLOC=WORK will be used instead.
NOTE: SAS initialization used:
real time 0.14 seconds
cpu time 0.13 seconds

NOTE: Remote signon to SASMAIN complete.
NOTE: Remote submit to SASMAIN commencing.
1 options nosource;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.AAA has 19 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.02 seconds


NOTE: Remote submit to SASMAIN complete.
#### 0 ####
NOTE: Remote signoff from SASMAIN commencing.
NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414
NOTE: The SAS System used:
real time 0.20 seconds
cpu time 0.16 seconds

NOTE: Remote signoff from SASMAIN complete.
NOTE: Remote signon to SASMAIN commencing (SAS Release 9.01.01M3P020206).
NOTE: Copyright (c) 2002-2003 by SAS Institute Inc., Cary, NC, USA.
NOTE: SAS (r) 9.1 (TS1M3)
Licensed to OMNITEL, Site 0088197007.
NOTE: This session is executing on the HP-UX B.11.23 platform.

NOTE: Running on HP Model ia64 Serial Number 4075303309.


NOTE: SAS 9.1.3 Service Pack 4

You are running SAS 9. Some SAS 8 files will be automatically converted
by the V9 engine; others are incompatible. Please see
http://support.sas.com/rnd/migration/planning/platform/64bit.html

PROC MIGRATE will preserve current SAS file attributes and is
recommended for converting all your SAS libraries from any
SAS 8 release to SAS 9. For details and examples, please see
http://support.sas.com/rnd/migration/index.html


This message is contained in the SAS news file, and is presented upon
initialization. Edit the file "news" in the "misc/base" directory to
display site-specific news and information in the program log.
The command line option "-nonews" will prevent this display.




NOTE: The paths specified with the UTILLOC option do not exist. UTILLOC=WORK will be used instead.
NOTE: SAS initialization used:
real time 0.14 seconds
cpu time 0.13 seconds

NOTE: Remote signon to SASMAIN complete.
NOTE: Remote submit to SASMAIN commencing.
ERROR: %SYSRPUT statement is valid only when OPTION DMR is in effect.
1 options nosource;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.AAA has 19 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds


NOTE: Remote submit to SASMAIN complete.
WARNING: Apparent symbolic reference REMOTEERRORFROMMACRO not resolved.
#### &RemoteErrorFromMacro ####
NOTE: Remote signoff from SASMAIN commencing.
NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414
NOTE: The SAS System used:
real time 0.20 seconds
cpu time 0.16 seconds

NOTE: Remote signoff from SASMAIN complete.
5 REPLIES 5
deleted_user
Not applicable
Hello,
it seems to me, that you have to execute the macro definition in a RSUBMIT/ENDRSUBMIT block to get the desired result. See the SAS/Connect doc regarding Compute Services: /Using Compute Services/Macro Statements.
"Macro statements that you include in a macro-generated RSUBMIT statement might get resolved and executed in the client session rather than in the server session, regardless of your including the statements in an RSUBMIT/ENDRSUBMIT statement block.The macro processor in the client session resolves variables that are specified in the following statements:
... %SYSRPUT"
A Programmin Technique, that might help you is stated under the topic:
Server Session Execution: Macro Definition in an RSUBMIT Block.

Good luck!

/norbert
SAS_user
Calcite | Level 5
Thank you Norbert,

That was helpfull.

I used

%nrstr(%%)sysrput RemoteErrorFromMacro = &error;
astha8882000
Obsidian | Level 7

I tried doing this too:

 

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

LIBNAME abc "&abc_unix.";

 

but 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.

PatrickG
SAS Employee
Yes. I think Norbert is correct. The %sysrput statement must be remote submitted to a server session, so I believe it does need to be between in and rsubmit / endrsubmit block (at least all the examples I can find in the SAS Doc have it that way...!).
astha8882000
Obsidian | Level 7
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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 2536 views
  • 0 likes
  • 4 in conversation