Identifying a Data Set and Returning Results

Goal

You want your application to open a specific data set and return either static or dynamic results. Your options depend on which SAS provider you are using.
This recipe applies to the local, SAS/SHARE, IOM, and Base SAS providers. Sample code for ADO is included.

ADO Implementation

Sample Code for Identifying Data Sets and Returning Results

The following table includes sample code that is used identify data sets and return results. Assume that a Connection object named obConnection is already open.
Sample Code for Identifying Data Sets
Provider
Comment and Sample Code
local
Specify the data set name. In the sample code, the data set name is family.
obRecordset.Open "family", obConnection, adOpenStatic, adLockReadOnly, _
     adCmdTableDirect
IOM, SAS/SHARE, and Base SAS
Use SAS libname.memname notation. In the sample code, the data set name is mylib.cities.
obRecordset.Open "mylib.cities", obConnection, adOpenStatic, _
     adLockReadOnly, adCmdTableDirect
The value of the CommandType property determines whether the recordset can be modified.
How the CommandType Value Affects Results
Value of the CommandType Property
Result
adCmdTableDirect
A dynamic open of a data set that can be modified. Command type adCmdTableDirect is used in the sample code and can be used with all of the providers.
adCmdTable
A static result set from a query that cannot be modified. Command type adCmdTable can be used only with the IOM, SAS/SHARE, and Base SAS providers because adCmdTable executes an SQL query in the form SELECT * FROM libname.memname. The local provider does not support SQL processing.

A Closer Look at Defining the SAS Library for the Server

SAS organizes tables in libraries. Before you can use a SAS library, you must tell SAS where it is. One way to identify the library is to use a libref, which is a short name (or alias) for the full physical name of the library. Before you can use the libname.memname notation, the libref that contains the data set must be defined for the server.
  • For the SAS/SHARE server, the libref is assigned when the server is started.
  • For a local installation of Base SAS, you assign the libref when you specify the "SAS Parameters" property in the connection code. The value of the "SAS Parameters" property contains the command line that includes code to start the server. For more information about the "SAS Parameters" property, see Connecting to Local Data (Single-User Server).
  • For the SAS Workspace Server, you can use ADO to assign a libref by executing a LIBNAME statement through an ADO Command object. Or you can use the IOM DataService class to assign a libref. For more information, see Specifying a Libref to Use with the IOM Provider.