SAS/CONNECT

What is SAS/CONNECT?

SAS/CONNECT is an application that provides client/server services between a local SAS session (desktop) and one or more remote SAS sessions (server). It offers two types of services, which both use SAS Windows as the front end:

Compute Services (CS) Remote Library Services (RLS)

Give user access to all of the computing resources on the remote host.

Give user access to all the data regardless of where they are stored. Data processing takes place in the remote server Data processing takes place in the local desktop Best to use if the amount of data involved is large Best to use if the amount of data involved is small to medium

Why Use SAS/CONNECT?

  • User who feels more comfortable in the Windows environment

  • Output and log displayed in SAS window

  • Take advantage of remote processing speed (CS)

  • Enable access to data that are too large or dynamic to be transferred or processed in the local system (CS)

  • Transparent access to remote data (RLS)

  • Allows user to combine remote and local data in one program (RLS)

  • Eliminate need to transfer or create additional copies of the data because user works on only one copy of the data (CS/RLS)

How SAS/CONNECT Works

  • SAS/CONNECT allows you to connect a SAS session running on your desktop to SAS on the research grid.

  • To make connection, SAS/CONNECT uses a communications access method (e.g. TCP/IP, DECnet, Telnet) specific to the environment.

  • Note: The server has SAS 9.2, but users may use either PC SAS version 9.3 or 9.4 to connect to SAS 9.2 on the server

Making a Connection with SAS/CONNECT Since HBS community uses primarily TCP/IP as the access method and RCS supports only Linux servers, the following sections will cover instructions and examples on how to make the connection based on the these communication protocol and server. To connect to Linux via TCP/IP, it is most convenient to use a script named 'sasconnect.scr' to start a link. A script is a file on the local system containing special SAS statements that control the connection. Please note: The connect script 'sasconnect.scr' is not included in version 9.4. If you are upgrading from version 9.3, the file 'sasconnect.scr' can be copied from the 9.3 path to the 9.4 path from: filename rlink "C:\Program Files\SASHome\SASFoundation\9.3\connect\saslink\sasconnect.scr"; to: filename rlink "C:\Program Files\SASHome2\SASFoundation\9.4\connect\saslink\sasconnect.scr"; If you don't have a copy of sasconnect.scr, please right click here and save the file in the following location: C:\Program Files\SASHome2\SASFoundation\9.4\connect\saslink\sasconnect.scr *Please note: Mozilla Firefox may save the file in.txt format, so if using this browser please rename the file to 'sasconnect.scr' Starting and Stopping SAS/CONNECT with an Automatic Logon Script There are a few ways to start SAS/CONNECT, but it is easiest to make the connection with an Automatic Logon Script. For users who would like to start and stop SAS/CONNECT using the menu bar or shortcuts, please refer to the Usage and Reference manual for SAS/CONNECT Software. Once you have downloaded the script file, the general steps to establish and terminate the link are as follows:

  • Start a SAS session on your local operating system (desktop or laptop)

  • In the PROGRAM EDITOR, type in the following:

%let rmt=sasconnect.hbs.edu 4016;

options comamid=tcp remote=rmt;

filename rlink "c:\xx\..\xx\sasconnect.scr";

signon connectstatus=yes script=rlink;

Be sure to use the correct path for the version of SAS 9 you are using.

When SAS reads the signon statement you will be asked for your username and password. Successful execution of the connection script will be indicated in the log window. You can now use SAS/CONNECT to remote submit SAS programs for execution on Unix or use RLS to access a file from Unix and process it locally.

When you have finished using SAS/CONNECT, you terminate the connection by clicking "Run" then "Signoff..." when the editor window is active. After the SIGNOFF command executes successfully, a message in the LOG window will indicate that the link has been terminated.

SAS Examples

The examples below make the connection via TCP/IP using an automatic logon script. They will help you understand how each of these services in SAS/CONNECT works and show how you may structure a program to make a link:

Example 1. Compute Services: Submit program remotely to UNIX

/**********************************************************************/; /* Compute Services: Sample script to submit program remotely to UNIX */; /**********************************************************************/; /* Set up the remote access environment: */ /* - Define the remote session in UNIX (=> rmt); */ /* - Specify the communication access method (=> comamid); */ /* - Specify a login script (-> filename rlink); */ %let rmt=sasconnect.hbs.edu 4016; options comamid=tcp remote=rmt; filename rlink "C:\Program Files\SASHome2\SASFoundation\9.4\connect\saslink\sasconnect.scr" /* If you use PC SAS 9.3, the above path will be: */ * filename rlink "C:\Program Files\SASHome\SASFoundation\9.3\connect\saslink\sasconnect.scr" /* Establish the connection using the UNIXTCP.SCR script file */ signon connectstatus=yes script=rlink; /* After SAS reads the signon statement and executes successfully, the LOG window */ /* will indicate that the link is established. You will be prompted for the UNIX */ /* username and password */ /* The commands between rsubmit and endrsubmit are passed to UNIX and executed there. */ /* The libnames and datasets are all relative to the remote server. */ /* For example, if you want to define a new libname on the server, you must use */ /* syntax appropriate to the server. */ /* Data placed in the temporary work space reside in the remote library and will be */ /* lost after the endrsubmit statement. */ rsubmit; libname rmtdata '/export/home/dor/jdoe'; * REPLACE PATH AND USERNAME WITH YOUR OWN; data rmtdata.test; array x{125}; do i=1 to 125; x{i}=ranuni(0); end; do i=1 to 1000; output; end; run; proc print data=rmtdata.test(obs=10); run; endrsubmit; signoff;

Example 2. Compute Services: Submit program remotely to WRDS

/**********************************************************************/; /* Compute Services: Sample script to submit program remotely to WRDS */ /**********************************************************************/; /* Set up the remote access environment: */ /* - Define the remote session in WRDS (=> wrds); */ /* - Specify the communication access method (=> comamid); */ %let wrds=wrds.wharton.upenn.edu 4016; options comamid=TCP remote=WRDS; signon username=_prompt_; /* After SAS reads the signon statement and executes successfully, the LOG window */ /* will indicate that the link is established. You will be prompted for the WRDS */ /* username and password */ /* The commands between rsubmit and endrsubmit are passed to WRDS and executed there. */ /* The libnames and datasets are all relative to the remote server. */ /* For example, if you want to define a new libname on the server, you must use */ /* syntax appropriate to the server. */ /* Data placed in the temporary work space reside in the remote library and will be */ /* lost after the endrsubmit statement. */ rsubmit; libname crsp '/wrds/crsp/sasdata'; proc means data=crsp.dport1; run; proc freq data=crsp.dport2; tables permno / out=dport2; run; proc print data=dport2; run; endrsubmit; signoff;

Example 3. Remote Library Services: Access remote data to process locally

/*******************************************************************/; /* RLS: Sample script to access remote data and process it locally */ /*******************************************************************/; /* Set up the remote access environment: */ /* - Define the remote session in UNIX (=> rmt); */ /* - Specify the communication access method (=> comamid); */ /* - Specify a login script (-> filename rlink); */ %let rmt=sasconnect.hbs.edu 4016; options comamid=tcp remote=rmt; filename rlink "C:\Program Files\SASHome2\SASFoundation\9.4\connect\saslink\sasconnect.scr" /* If you use PC SAS 9.3, the above path will be: */ * filename rlink "C:\Program Files\SASHome\SASFoundation\9.3\connect\saslink\sasconnect.scr" /* Establish the connection using the UNIXTCP.SCR script file */ signon connectstatus=yes script=rlink; /* After SAS reads the signon statement and executes successfully, the LOG window */ /* will indicate that the link is established. You will be prompted for the UNIX */ /* username and password */ /* Define remote library. The value for server is the same as the remote session id */ * PUT IN YOUR HOME DIRECTORY AND LOGIN NAME; libname rmtdata '/export/home/homedir/username' server=rmt; /* Define local drive location -- modify as necessary */ libname lcldata 'C:\Documents and Settings\hbsuser\My Documents\My SAS Files\'; /* Proc Freq on the remote data is processed locally */ proc freq data=rmtdata.salesdat; tables type; run; /* The WHERE statement moves only the type BP observations and processes them locally.*/ /* It avoids moving every observation from the remote host and filters out the */ /* the unneeded observations */ data lcldata.subsetdata; set rmtdata.salesdat; where type='BP'; proc print; run; signoff;

If you would like assistance with SAS/CONNECT, please contact Christine Rivera (5-6046), Senior Statistician/Data Scientist, Research Computing Services.