Submitting SAS Programs to a Grid Interactively

Overview

You can use SAS Display Manager as a client to submit SAS programs to the grid for execution. The results of the execution are returned to the local workstation. When you submit a SAS program from a SAS Display Manager client to execute on a grid, the program runs on a grid machine in a separate session with its own unique work library. The SAS log and output of the grid execution are returned to the local workstation. You might need to perform additional actions in order to view data from the SAS Display Manager session that was created or modified by the program that ran on the grid. For example, modifications might be required in order to use the Explorer to browse SAS libraries that are modified by grid execution.
Starting with the first maintenance release after SAS 9.4, you can also use the SAS Grid Manager Client Utility to start an interactive session on the grid or watch the output from a batch session. An interactive session enables you to perform functions in interactive mode or batch monitor mode:
Interactive mode
  • Run SAS in line mode.
  • Run SAS in Display Manager mode.
  • Run and interact with a command (watch the output and provide input).
Batch monitor mode
  • Run SAS in batch mode and watch the output of the session.
  • Run a command in batch mode and watch the output.
Using SAS line mode or SAS Display Manager mode requires that the grid nodes are UNIX machines. Also, SAS Display Manager mode requires that you have X Server on the client machine.
If you terminate the SAS Grid Manager Client Utility session while performing any interactive mode function, the remote job is also terminated. Terminating the session while running a batch monitor mode function does not terminate the batch job.

Submitting Jobs from the Program Editor to the Grid

The first step in integrating SAS processes with the grid is to get your SAS programs running on the grid.
In order to submit a SAS program to the grid, you must add a set of grid statements to the program. For programs submitted through the SAS Program Editor, you can save the statements to an external file and then specify a key definition that issues the statements. Submit the contents of the SAS Program Editor window to the grid, rather than to the local workstation.
Some of the examples in this topic use SAS/CONNECT statements (such as signon, rsubmit, and signoff). For detailed information about these statements, see SAS/CONNECT User's Guide.
Note: This procedure does not work if the Explorer window is open in your SAS session.
To add grid statements to a program and submit the program to the grid, follow these steps:
  1. Save these statements to an external file, referred to as grid-statement-file (for example, c:\gpre.sas):
    %global count; 
    %macro gencount; 
    %if %bquote(&count) eq %then %do; %let count=1;%end;%else %let
    count=%eval(&count+1); 
    %mend; 
    %gencount; 
    options
    metaserver='metadata-server-address'; 
    options metaport=metadata-server-port; 
    options metauser=username; 
    options metapass="password"; 
    %let rc=%sysfunc(grdsvc_enable(grid&count, server=SASApp));
     signon grid&count;
    metadata-server-address is the machine name of the SAS Metadata Server, and metadata-server-port is the port used to communicate with the metadata server.
  2. Open the Keys window and specify the following for an available key (for example, F12):
    gsubmit ”%include
    'grid-statement_file';”;
    rsubmit grid&count wait=no persist=no;
    grid-statement-file is the path and filename of the file (for example, c:\gpre.sas) containing the grid statements.
  3. Type or include a SAS program in the Program Editor window, and then press the key assigned to the grid statements. The program is automatically submitted to the grid for processing. Your local machine is busy only until the program is submitted to the grid.
Using the same key to submit multiple jobs causes multiple jobs to be executed in parallel on the grid. Anything specified in the WORK library is discarded when the grid session ends and is not available to later steps in the code.

Viewing LOG and OUTPUT Lines from Grid Jobs

The example in Submitting Jobs from the Program Editor to the Grid uses asynchronous rsubmits. This causes the results of the execution to be returned to the local log and output windows only after the entire program finishes execution on the grid. To cause the log and output lines to be displayed while the program is executing, delete the options noconnectwait; line in the program.
The rsubmit executes synchronously, and the returned log and output lines are displayed while the job is executing. This also results in the Client SAS session being busy until the entire grid job has completed. You cannot submit more code until the job completes.

Using the SAS Explorer Window to Browse Libraries

The Client SAS session and the grid SAS session are two separate instances of SAS. Any code or products needed to access data must be submitted and available on both the client machine as well as the grid nodes. Use the following steps to browse libraries from the SAS Explorer Window that are accessed and modified by jobs executing in the grid:
  1. Define all of your SAS libraries within SAS metadata under your server context (for example, under SASApp).
  2. Ensure that the following option is in the SAS invocation in the sasgrid script file used to start SAS on the grid nodes. This option should have been added by the SAS Deployment Wizard.
    metaautoresources SASApp
    SASApp is the name of your application server context.
  3. Include this option on the Client SAS session invocation on the workstation.
    metaautoresources SASApp
    SASApp is the name of your application server context.
    Note: If you are accessing data through any SAS/ACCESS product, you must license the SAS/ACCESS products on the SAS Client machine in order to be able to browse those libraries from the SAS Explorer. The SAS/ACCESS products must also be licensed on the grid nodes in order to enable the job to access data during execution.
Each SAS session executing on the grid is a unique session with a unique WORK library. In order to view the work libraries that are created on each of the grid nodes, you must add the following line after the signon statement in the code provided in Submitting Jobs from the Program Editor to the Grid:
libname workgrid slibref=work server=grid&count;
grid&count is the label used as the remote session ID in the signon statement.

Running Interactive SAS Sessions Using the SAS Grid Manager Client Utility

To start an interactive SAS session on a UNIX grid using the SAS Grid Manager Client Utility and SAS Display Manager, issue the following command from an operating system command line:
<path/>SASGSUB -GRIDRUNSASDMS <hostName>:display_number<.screen_number>
To start an interactive SAS session in line mode on a UNIX grid using the SAS Grid Manager Client Utility, issue the following command from an operating system command line:
<path/>SASGSUB -GRIDRUNSASLM
The path option specifies the path for the SASGSUB program. By default, the location is <configuration_directory>/Applications/SASGridManagerClientUtility/<version>.
The -GRIDRUNSASDMS or -GRIDRUNSASLM option starts the interactive SAS session on the grid. Once the session has started, you can submit SAS code or programs that will run on the machine in the grid. There are other arguments, some required and some optional, that you can include in the SASGSUB statement. These arguments are passed to the grid when the SAS session is started and include parameters such as the metadata connection information, grid application server name, and workload resource names. See SASGSUB Syntax: Starting SAS in Interactive Mode for complete syntax information.

Running Interactive Commands Using the SAS Grid Manager Client Utility

To interactively run a command on a grid using the SAS Grid Manager Client Utility, issue the following command from a SAS command line:
<path/>SASGSUB -GRIDRUNCMDINT command
Standard input, standard output, and standard error are directed to your command prompt window.