To specify
which file format that the local provider should use to access a data
source, set the "SAS File Format" property on the Connection object.
You can use the following property values:
-
"V9" (the default) for SAS 9.2
and earlier (also valid for SAS 8 and SAS 7 data sets)
-
"V8" for SAS 8 or SAS 7 data sets
-
"V7" for SAS 7 or SAS 8 data sets
-
-
"XPT" for SAS 5 transport files
For
example, the following Visual Basic code could be used to access a
SAS Version 6 data set named HRdata that is stored in a directory
named
c:\v6data
.
Dim obConnection As New ADODB.Connection
Dim obRecordset As New ADODB.Recordset
obConnection.Provider = "sas.LocalProvider"
obConnection.Properties("Data Source") = "c:\v6data"
obConnection.Properties("SAS File Format") = "V6"
obConnection.Open
obRecordset.Open "HRdata", obConnection, adOpenStatic, adLockReadOnly, adCmdTableDirect
The code
in the next example can read a SAS data set named TestDs1 from a Version
5 SAS transport file named xport1.dat:
Dim obConnection As New ADODB.Connection
Dim obRecordset As New ADODB.Recordset
obConnection.Provider = "sas.LocalProvider"
obConnection.Properties("Data Source") = "c:\xptdata\xport1.dat"
obConnection.Properties("SAS File Format") = "XPT"
obConnection.Open
obRecordset.CursorType = adOpenStatic
obRecordset.LockType = adLockReadOnly
obRecordset.Open "TestDs1", obConnection, adOpenStatic, adLockReadOnly, adCmdTableDirect