Using SAS Enterprise Guide with a SAS Grid

Submitting SAS Programs to the Grid Using SAS Enterprise Guide

SAS Enterprise Guide provides an option to automatically add the necessary grid statements to all submitted programs or tasks. To run programs submitted from SAS Enterprise Guide on the grid, follow these steps:
  1. In SAS Enterprise Guide, select Toolsthen selectOptions to open the Options window.
  2. In the Options window, select SAS Programs. To enable SAS Enterprise Guide tasks to run on a SAS grid, select Tasksthen selectCustom Code instead.
  3. Select Insert custom SAS code before submitted code and then click Edit.
  4. In the Edit window, enter these SAS statements:
    options metaserver='metadata-server-address';
    options metaport=metadata-server-port;;
    %let rc=%sysfunc(grdsvc_enable(_all_,resource=SASApp));
    signon task1;
    rsubmit;
  5. In the Options window, select Insert custom SAS code after submitted code, and then click Edit.
  6. In the Edit window, enter these SAS statements:
    endrsubmit;
    signoff;
  7. While testing, if you want to verify that the program ran on the grid, include this statement before the signoff statement:
    %put This code ran on the machine %sysfunc(grdsvc_getname(task1));
    You should remove this statement when the code runs in a production environment.
Alternatively, you can run SAS Enterprise Guide jobs on a grid through workspace server load balancing. After you set up a workspace server to use load balancing, you can submit SAS Enterprise Guide jobs to the server to automatically use the load balancing capability. See Using SAS Grid Manager for Workspace Server Load Balancing.

Generating ODS Output on the Grid Using SAS Enterprise Guide

You can specify options for the results of SAS programs or tasks that are run by SAS Enterprise Guide. If you are running these programs and tasks on a grid, you must propagate these settings to all grid nodes so that the output from the nodes is formatted properly. To apply the result settings to all grid nodes, follow these steps:
Note: This procedure requires either SAS Enterprise Guide Version 4.22 or Version 4.1 with hotfix 11 (41EG11) applied.
  1. In SAS Enterprise Guide, select Toolsthen selectOptionsthen selectResults to specify the result options.
  2. In the SAS Enterprise Guide Options window, select Resultsthen selectResults General. Uncheck the Link handcoded ODS results check box.
    This option enables the temporary files that are used by the grid sessions to be copied to the local SAS Enterprise Guide project directories.
  3. Close the Options window.
  4. Edit the SAS\Enterprise Guide 4\SEGuide.exe.config file and add this line:
    <add key="OdsOptionsToMacro" value="true" />
    This statement causes SAS Enterprise Guide to generate macro statements for the results options that you specified.
  5. (Optional) If all programs and tasks submitted from SAS Enterprise Guide will run on the grid, you can add a statement to suppress the ODS statements for the SAS Workspace Server. This statement eliminates all of the default ODS result entries in the workspace and forces the programs to use the settings that are in place on the grid nodes.
    Add this line to the SAS\Enterprise Guide 4\SEGuide.exe.config file:
    <add key="SuppressODSStetements" value="true" />
  6. Restart SAS Enterprise Guide.
After the change is applied, SAS Enterprise Guide applies the result option settings to a set of macros. For example, if HTML is set as the only result output, the macro statements will look like this:
/* BEGIN: SAS Enterprise Guide results options */ 
%LET _GOPT_DEVICE = ACTIVEX; 
%LET _GOPT_XPIXELS = 0; 
%LET _GOPT_YPIXELS = 0; 
%LET _GOPT_GFOOTNOTE = NOGFOOTNOTE; 
%LET _GOPT_GTITLE = NOGTITLE; 
%LET _ODSOPTIONS_GRAPHCODEBASE = ATTRIBUTES=("CODEBASE"="http://www2.sas.com/
   codebase/graph/v91/sasgraph.exe"); 
%LET _ODSDEST_LISTING = ; 
%LET _ODSDEST_HTML = HTML; 
%LET _ENCODING_HTML = utf-8; 
%LET _ODSSTYLE_HTML = Analysis; 
%LET _ODSSTYLESHEET_HTML = (URL="http://support.sas.com/styles/analysis.css"); 
%LET _ODSDEST_RTF = ; 
%LET _ODSDEST_PDF = ; 
%LET _ODSDEST_SRX = ; 
/* END: SAS Enterprise Guide results options */ 
You can then add macros to the grid wrapper code to evaluate the active preferences and propagate the appropriate settings to the grid session. The wrapper code for the macros listed previously looks like the following:
options metaserver='server1.domain.com';
options metaport=8561;
%let rc=%sysfunc(grdsvc_enable(_all_,resource=SASMain));
signon task1;
%include "c:\htmllocal.sas" ;
%include "c:\rtflocal.sas" ;
%include "c:\pdflocal.sas" ;
%include "c:\srxlocal.sas" ;
rsubmit;
ODS _ALL_ CLOSE;
%inc "c:\htmlremote.sas" ;
%inc "c:\rtfremote.sas" ;
%inc "c:\pdfremote.sas" ;
%inc "c:\srxremote.sas" ;
The settings for each type of output are contained in a set of *local.sas macro files (such as htmllocal.sas). The files use the %SYSRPUT macro to propagate the settings to the grid session.
The ODS option statements are submitted through a set of *remote.sas macro files (such as htmlremote.sas).
Sample SEGuide.exe.config files (for both SAS Enterprise Guide 4.22 and 4.1) as well as sample macro wrappers and sample *local.sas and *remote.sas macro files are available at http://support.sas.com/rnd/scalability/grid/download.html.

Accessing Temporary Files Between Grid Nodes

SAS Enterprise Guide stores output data in the SASUSER library on the SAS Workspace Server machine, or in the EGTASK library if that library is defined. When a job or task from SAS Enterprise Guide runs on a grid, there are temporary work files that might need to be accessed between the grid nodes. In order for the multiple SAS grid sessions to be able to access these files, you must define a permanent shared library.
To create a permanent shared library for SAS Enterprise Guide jobs, use one of these methods:
  • Use SAS Management Console to define the EGTASK library, pointing it to a shared storage location. Mark the library definition as Pre-assigned so that it is defined each time a grid session is started. If you use this method, you have to change only one library definition if you want to change the storage location.
  • Add an environment variable to the sasgrid.cmd (Windows) or sasgrid (UNIX) file that defines the EGTASK LIBNAME, pointing the library to a shared location. If you run the sasgrid.cmd or sasgrid file from a shared location, you have to change the LIBNAME definition statement only once if you want to change the library's location.
  • Add the EGTASK LIBNAME statement to the autoexec file, pointing the library to a shared location. After the LIBNAME statement is added, add the -AUTOEXEC option to the command used to start SAS in the sasgrid.cmd (Windows) or sasgrid (UNIX).

Making SASWORK Libraries Visible to SAS Enterprise Guide

If you want the SASWORK libraries created by the grid sessions to be visible in the Library window of SAS Enterprise Guide, add a LIBNAME statement after the rsubmit statement in the grid wrapper code. For example, add this statement:
libname work1 (work);
The Library window will display the WORK1 library. You can then use this library window to display the contents of the library.

Assigning SAS Enterprise Guide Libraries in a Grid

In SAS 9.2 and later versions, SAS sessions on the grid use the METAAUTORESOURCES option by default. This option causes SAS libraries that are defined in metadata and identified as “pre-assigned” to automatically be assigned when the SAS session is started. Using pre-assigned libraries with the METAAUTORESOURCES option ensures that the libraries used in the code generated by SAS Enterprise Guide are available to the SAS sessions on the grid.
However, if your programs use a large number of libraries, you might not want to make all of these libraries pre-assigned. Automatically assigning a large number of libraries could cause performance problems, and not all libraries are likely to be used for all programs. To minimize the performance overhead, define the libraries in SAS metadata but do not identify them as pre-assigned. When you need to refer to the library, you can then use a LIBNAME statement using the META LIBNAME engine.

Developing SAS Programs Interactively Using SAS Enterprise Guide and a Grid

Maintaining a Connection to the Grid

By default, when you start SAS Enterprise Guide, it connects to a single workspace server and keeps that connection active for the length of the session. If you interactively develop programs in SAS Enterprise Guide by highlighting and submitting lines of code, the codes uses items such as libraries, WORK files, and SAS global statements on the workspace server. If you are using SAS Enterprise Guide in a grid environment, the items such as libraries and SAS global statements must be accessed through the grid, rather than a single workspace server. To maintain access to these items, you must maintain a connection to the grid while you are developing programs interactively.
To keep the connection between SAS Enterprise Guide and the grid active, remove the signoff statement from the wrapper code that executes at the end of each SAS Enterprise Guide program or task submitted to the grid. See Submitting SAS Programs to the Grid Using SAS Enterprise Guide for the statements in the wrapper code.

Setting Workload Values

When SAS Enterprise Guide is used for interactive program development, the workload is likely to consist of short bursts of work interspersed with varying periods of inactivity while the user considers their next action. The SAS grid configuration can best support this scenario with these configuration settings:
  • Increase the number of job slots for each machine.
    Increasing the number of job slots increases the number of simultaneous SAS sessions on each grid node. Because the jobs that are run on the grid are not I/O or compute intensive like large batch jobs, more jobs can be run on each machine.
  • Implement CPU utilization thresholds for each machine.
    If all users submit CPU-intensive work at the same time, SAS Grid Manager can suspend some jobs and resume the suspended jobs when resources are available. This capability prevents resources from being overloaded.
The following example shows a sample LSB.HOSTS file that is configured with job slots set to 12 and CPU utilization thresholds set to 80%. The settings needed for a specific site will depend on the number of users and the size of the grid nodes.
HOST_NAME MXJ    ut        r1m     pg    ls    tmp  DISPATCH_WINDOW  #Keywords
#default   !     ()         ()     ()    ()     ()     ()            #Example
host01     12    0.7/0/8    ()     ()    ()     ()     ()            # host01
host02     12    0.7/0/8    ()     ()    ()     ()     ()            # host02
host03     12    0.7/0/8    ()     ()    ()     ()     ()            # host03
host04     12    0.7/0/8    ()     ()    ()     ()     ()            # host04
host05     12    0.7/0/8    ()     ()    ()     ()     ()            # host05
End Host