DATA Step, Macro, Functions and more

%sysrput statement don't work from macro's

Reply
Contributor
Posts: 48

%sysrput statement don't work from macro's

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.
N/A
Posts: 0

Re: %sysrput statement don't work from macro's

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
Contributor
Posts: 48

Re: %sysrput statement don't work from macro's

Thank you Norbert,

That was helpfull.

I used

%nrstr(%%)sysrput RemoteErrorFromMacro = &error;
SAS Employee
Posts: 58

Re: %sysrput statement don't work from macro's

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...!).
Ask a Question
Discussion stats
  • 3 replies
  • 537 views
  • 0 likes
  • 3 in conversation