%SYSRPUT Statement

Assigns the value of a macro variable on a remote host to a macro variable on the local host.
Type: Macro statement
Restriction: Allowed in macro definitions or open code
Requirement: SAS/CONNECT
See: SYSERR Automatic Macro Variable, SYSINFO Automatic Macro Variable, and %SYSLPUT Statement

Syntax

%SYSRPUT local-macro-variable=remote-macro-variable;

Required Arguments

local-macro-variable
is the name of a macro variable with no leading ampersand or a text expression that produces the name of a macro variable. This name must be a macro variable stored on the local host.
remote-macro-variable
is the name of a macro variable with no leading ampersand or a text expression that produces the name of a macro variable. This name must be a macro variable stored on a remote host.

Details

The %SYSRPUT statement is submitted with SAS/CONNECT to a remote host to retrieve the value of a macro variable stored on the remote host. %SYSRPUT assigns that value to a macro variable on the local host. %SYSRPUT is similar to the %LET macro statement because it assigns a value to a macro variable. However, %SYSRPUT assigns a value to a variable on the local host, not on the remote host where the statement is processed. The %SYSRPUT statement places the macro variable into the global symbol table in the client session.
Note: The names of the macro variables on the remote and local hosts must not contain a leading ampersand.
The %SYSRPUT statement is useful for capturing the value of the automatic macro variable SYSINFO and passing that value to the local host. SYSINFO contains return-code information provided by some SAS procedures. Both the UPLOAD and the DOWNLOAD procedures of SAS/CONNECT can update the macro variable SYSINFO and set it to a nonzero value when the procedure terminates due to errors. You can use %SYSRPUT on the remote host to send the value of the SYSINFO macro variable back to the local SAS session. Thus, you can submit a job to the remote host and test whether a PROC UPLOAD or DOWNLOAD step has successfully completed before beginning another step on either the remote host or the local host.
For details about using %SYSRPUT, see the documentation for SAS/CONNECT Software.
To create a new macro variable or modify the value of an existing macro variable on a remote host or server, use the %SYSLPUT macro statement.

Example: Checking the Value of a Return Code on a Remote Host

This example illustrates how to download a file and return information about the success of the step from a noninteractive job. When remote processing is completed, the job then checks the value of the return code stored in RETCODE. Processing continues on the local host if the remote processing is successful.
The %SYSRPUT statement is useful for capturing the value returned in the SYSINFO macro variable and passing that value to the local host. The SYSINFO macro variable contains return-code information provided by SAS procedures. In the example, the %SYSRPUT statement follows a PROC DOWNLOAD step, so the value returned by SYSINFO indicates the success of the PROC DOWNLOAD step:
rsubmit;
   %macro download;
      proc download data=remote.mydata out=local.mydata;
      run;
      %sysrput retcode=&sysinfo;
   %mend download;
   %download
endrsubmit;
%macro checkit;
   %if &retcode = 0 %then %do;
      further processing on local host
   %end;
%mend checkit;
%checkit
A SAS/CONNECT batch (noninteractive) job always returns a system condition code of 0. To determine the success or failure of the SAS/CONNECT noninteractive job, use the %SYSRPUT macro statement to check the value of the automatic macro variable SYSERR. To determine what remote system the SAS/CONNECT conversation is attached to, remote submit the following statement:
%sysrput rhost=&sysscp;