Starting a Single-User Local Server with the SAS/SHARE Provider

In this recipe, you learn how to use the SAS/SHARE Data Provider to start a local server so that a single user can access data that is located on the same machine. Sample code for the ADO recipe is included.

Applies to: SAS/SHARE Data Provider
Implement using: ADO or OLE DB


You can use the SAS/SHARE Data Provider to start a local server for use by a single user to access data that is located on the same machine. The local server is available if the local machine has the SAS Base product installed and licensed. You must also add an entry to the TCP/IP services file for the server ID that you want to use.

The following Visual Basic code fragment shows you how to start a local server with sdplserv as the server ID:

obConnection.Provider = "sas.ShareProvider.1"
obConnection.Properties("Data Source") = "sdplserv"
obConnection.Properties("SAS Local Server") = 1
obConnection.Properties("SAS Executable") = "C:\\Program Files\\SAS Institute\\SAS\\V8\\sas.exe"
obConnection.Properties("SAS Parameters") = "-initstmt %sasodbc(sdplserv) -icon -nologo"
obConnection.Properties("SAS Working Directory") = "C:\\Program Files\\SAS Institute\\SAS\\V8\\"
' Set other connection properties...


The properties used in the sample code are explained in the following table.

Note: For information about other SAS/SHARE provider connection properties, see Opening an ADO Connection Object.

Property Value
"SAS Local Server" Determines if the SAS/SHARE provider will start a local server. The value for this property can be 0 or 1. 0 is the default value and indicates that the provider should not start a server. 1 is the direction to start a local server.
"SAS Executable" The fully qualified path to the SAS executable file. You can use this property to start different server versions by setting the path to the version you want to start. The default value will be the standard installation location of the latest major SAS release.
"SAS Parameters" The command line options used to start the SAS executable. "SAS Parameters" must include an -initstmt, which executes a SAS Macro file to start the local server. The default value for this property uses the macro file, which is also used by the SAS ODBC driver. Any changes to will affect the SAS ODBC driver. See About the Macro for more information.
"SAS Working Directory" The fully qualified path to the SAS executable working directory, which is usually where your SAS program files and documents are located. The default value will be the standard installation directory of the latest major SAS release. This is not the directory for the Work libref.

TCP/IP Services File

The TCP/IP services file contains information about the services available on the local machine, including available SAS servers. For each named service, the file specifies a port number, a protocol name, and any service alias.

The TCP/IP services file is not stored in the same location on all platforms. However, for the Windows NT, Windows 2000, and Windows XP platforms, the services file is stored at c:\winnt\system32\drivers\etc\services.

Entries in the services file have the following general form:

<service-name>  <port-number/protocol-name>  <aliases>  #  <comments>

To add an entry for the SAS server that the SAS/SHARE provider will use for local access,

For example, if you configure the SAS/SHARE provider to access a local server named sdplserv, you must add the following entry to the services file (substituting the appropriate port number):

sdplserv		5420/tcp		# Share Provider Local Server

About the Macro

The %sasodbc macro is shipped with SAS and is found in !SASROOT\CORE\SASMACRO\SASODBC.SAS .

Note: !SASROOT is the logical name for the directory in which you install SAS. For more information, see the SAS 9.1 Companion for Microsoft Windows.

The SASODBC.SAS file executes the ODBCSERV procedure. The server ID for ODBCSERV is set to the parameter passed into the %sasodbc macro. By default, the server ID is set to sdplserv.

You can modify the SASODBC.SAS file to include additional SAS system options or SAS statements such as the LIBNAME statement. You can also specify options for PROC ODBCSERV. The available options for PROC ODBCSERV are identical to the PROC SERVER statement options. See the SAS/SHARE 9.1 User's Guide for details.

Because modifications to SASODBC.SAS will affect the behavior of the SAS ODBC Driver, you should create a separate SAS macro file for the SAS/SHARE provider if you also use the SAS ODBC Driver. If you create a new SAS macro file, make sure that you specify PROC ODBCSERV and not PROC SERVER.