Chapter Contents

Previous

Next
%SYSRPUT Statement

%SYSRPUT Statement



Assigns a value that is on the remote host to a macro variable on the local host.

Remote


Syntax
Syntax Description
Example 1
Example 2
Example 3

Syntax

%SYSRPUT macro-variable=value;

Syntax Description

macro-variable
specifies the name of a macro variable on the local host.

value
is a macro variable reference or a character string on the remote host that will be assigned to the macro-variable.

Details

The %SYSRPUT statement is a macro statement submitted to the remote host to assign a value that is available on the remote host to a macro variable that can be accessed on the local host. Value can be a macro variable reference or a character string. The %SYSRPUT statement is similar to the %LET statement because it is used to assign a value to a macro variable; however, the %SYSRPUT statement 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 current referencing environment of the local host.

A synchronization point identifies the point during an asynchronous RSUBMIT at which the macro variable that is specified in the %SYSRPUT statement will be defined to the local SAS session so that users can use it in their local processing.

There are three possible synchronization points.

  1. The first synchronization point occurs when the RGET command is executed. At this point, all macro variables that were specified by using %SYSRPUT are merged with the local SAS session and are available for processing.

  2. The second synchronization point can occur if a synchronous RSUBMIT is started to the same session in which an asynchronous RSUBMIT is already running. When this occurs, all currently spooled log and output statements are retrieved and merged into the local log and output windows, and the remote submit continues from that point as if it were synchronous. That is, you do NOT regain control until the remote submit has completed. In addition, %SYSRPUT macro variables are synchronized with those variables that are generated during the asynchronous remote submit processing up to that point. However, from that point on, it becomes a synchronous remote submit, and macro variables are synchronized immediately when they are executed.

    To override the default for asynchronous remote submits, the CSYSRPUTSYNC option may be specified in the asynchronous RSUBMIT statement, so that local macro variables are set at the time of execution rather than waiting for a synchronization point.

  3. The third synchronization point occurs when the SIGNOFF command or the SIGNOFF statement is executed. At this point, all macro variables that were specified by using %SYSRPUT are merged with the local SAS session and are available for processing.


Example 1

This example illustrates how to download a file and return information about the success of the step from a non-interactive job. When remote processing is completed, the job 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 that is returned in the SYSINFO macro variable and passing that value to the local host. The SYSINFO macro variable contains return-code information that is provided by SAS procedures. In the following example, the %SYSRPUT statement follows a PROC DOWNLOAD statement. The value that is returned by %SYSINFO indicates the success of the PROC DOWNLOAD statement:

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 (non-interactive) job always returns a system condition code of 0. To determine the success or failure of the SAS/CONNECT non-interactive job, use the %SYSRPUT macro statement to check the value of the automatic macro variable SYSERR. For more information about the SYSERR macro variable, refer to SAS Macro Language: Reference.


Example 2

This example executes an asynchronous remote submit. The CSYSRPUTSYNC= option is specified so that the local macro variable is set when %SYSRPUT executes, rather than waiting until the synchronization point is reached. This way, you are able to get status information about how the asynchronous remote submit is progressing by checking the value of the macro variable STATUS.

rsubmit cwait=no csysrputsync=yes;
   %sysrput status=start;
   proc download inlib=sales outlib=tmp 
      status=n;
   run;
   %sysrput status=salescomplete;

   proc download inlib=inventry outlib=tmp 
      status=n;
   run;
   %sysrput status=inventrycomplete;

   proc upload data=sales.store10 status=n;
   run;
   %sysrput status=storecomplete;
endrsubmit;


Example 3

This example shows how to determine what remote system the SAS/CONNECT conversation is attached to.

Remote submit the following statement:

%sysrput rhost=&sysscp;

To copy the value of RHOST into a local variable for further manipulation, use the following statement:

newvar="&rhost";

Double quotes (") must be used for character values.


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.