%SYSRPUT Statement

Assigns a value from the server session to a macro variable in the client session.
Valid in: server session

Syntax

%SYSRPUT macro-variable=value;

Syntax Description

macro-variable
specifies the name of a macro variable in the client session.
value
is a macro variable reference, a macro invocation, or a character string in the server session that will be assigned to the macro-variable in the client session.

Details

Overview

The %SYSRPUT macro statement is remotely submitted to the server session in order to assign a value that is available in the server session to a macro variable that can be accessed from the client session.
Like the %LET statement, the %SYSRPUT statement assigns a value to a macro variable. Unlike %LET, the %SYSRPUT statement assigns a value to a variable in the client session, not in the server session where the statement is executed. The %SYSRPUT statement stores the macro variable in the Global Symbol Table in the client session.
A synchronization point identifies the time (during an asynchronous RSUBMIT) at which the macro variable that is specified in the %SYSRPUT statement is defined to the client session and is available for execution in the client session.

Synchronization Points

Here are the three possible synchronization points:
  1. when the RGET command is executed.
    At this time, all macro variables that were specified by using %SYSRPUT are defined in the client session and are available for execution.
  2. when a synchronous RSUBMIT is started in the same server session that an asynchronous RSUBMIT is already running in.
  3. when the SIGNOFF command or the SIGNOFF statement is executed.
    All macro variables that were specified using %SYSRPUT are defined in the client session and are available for execution.
All currently spooled log and output statements are retrieved and merged into the client Log and Output windows. RSUBMIT continues from then on as if it were synchronous. Control is returned to the client session after the RSUBMIT has completed. In addition, %SYSRPUT macro variables that have been generated during the asynchronous RSUBMIT up to that point are defined in the client session. Thereafter, RSUBMIT becomes synchronous, and macro variables are synchronized immediately when they are executed.
To override the default for an asynchronous RSUBMIT, you can specify the SYSRPUTSYNC= option in the RSUBMIT statement. Macro variables are set at the time of execution rather than at a synchronization point in the client session.

Examples

Example 1: %SYSRPUT

The %SYSRPUT statement is useful for capturing the value that is returned in the SYSINFO macro variable and for passing that value to the client session. The SYSINFO macro variable contains return-code information that is provided by SAS procedures.
This example shows how to download a file and to return information about the success of the step from a batch job.
Using %SYSRPUT To Find Out Whether a Download Is Successful
signon rhost;
rsubmit;
   proc download data=remote.mydata 
         out=local.mydata;
   run;
   %sysrput retcode=&sysinfo;
endrsubmit;
%macro checkit;
   %if &retcode=0 %then %do;
      code-to-be-executed-in-client–session
   %end;
%mend checkit;
%checkit;
The %SYSRPUT statement occurs after a PROC DOWNLOAD statement. The value that is returned by &SYSINFO indicates the success of the PROC DOWNLOAD statement. After execution in the server session has completed, the value of the return code that is stored in RETCODE is checked. If server execution is successful, execution continues in the client session.
If SIGNON, RSUBMIT, or SIGNOFF fails, a SAS/CONNECT batch job returns a non-zero system condition code. To find out the status of an RSUBMIT execution, use the %SYSRPUT statement. This macro checks the value of the automatic macro variable SYSERR. For details, see SAS Macro Language: Reference.

Example 2: %SYSRPUT

This example shows the execution of an asynchronous RSUBMIT. The SYSRPUTSYNC= option is specified in order to set the client session's macro variable when %SYSRPUT executes rather than when a synchronization point is encountered. The value of the macro variable STATUS can be checked to monitor the progress of the asynchronous RSUBMIT.
Using %SYSRPUT To Monitor the Progress of an Asynchronous RSUBMIT
rsubmit wait=no csysrputsync=yes;
   %sysrput status=start;
   proc download inlib=sales outlib=tmp 
      status=n;
   run;
   %sysrput status=salescomplete;
   proc download inlib=inventory outlib=tmp 
      status=n;
   run;
   %sysrput status=inventorycomplete;
   proc upload data=sales.store10 status=n;
   run;
   %sysrput status=storecomplete;
endrsubmit;

Example 3: %SYSRPUT

This example shows how to identify the server session that the client session is signed on to:
rsubmit;
%sysrput rhost=&sysscp;
endrsubmit;