Previous Page | Next Page

Pass-Through Facility: PC Files on Linux, UNIX, and 64-Bit Microsoft Windows

CONNECT Statement



Establishes a connection with the data source.
Valid in: PROC SQL steps

Syntax
Arguments
Database Connection Arguments
CONNECT Statement Arguments
Details
Example

Syntax

CONNECT TO <data-source-name> AS <alias> (<connect-statement-arguments> <database-connection-arguments>);


Arguments

data-source-name

identifies the data source to which you want to connect. Because this method requires connecting through a PC Files Server, you must use PCFILES as your data source. You can also specify an optional alias in the CONNECT statement.

alias

specifies an optional alias for the connection that has 1 to 32 characters. If you specify an alias, the keyword AS must appear before the alias. If an alias is not specified, the data source name is used as the name of the pass-through connection.

connect-statement-arguments

specifies arguments that indicate whether you can make multiple connections, shared connections or unique connections, and so on, to the database.

database-connection-arguments

specifies the data source-specific arguments that are needed by PROC SQL to connect to the data source. These arguments are not required. The default behavior opens a dialog box with prompts to specify connection information.


Database Connection Arguments

The arguments that are listed below are available with the Pass-Through Facility for PC files. These arguments provide information to the Pass-Through Facility to connect to the PC files or to the database. These options are used when connecting to PC Files Server.

DSN=data-source-name

specifies the ODBC data source name that is used to access the PC data through an ODBC driver on the PC.

Note:   This ODBC data source must be defined on the PC where the PC Files Server is currently running.  [cautionend]

CONNECT_STRING=connection-string

specifies connection options for your data source or database. Separate multiple options with a semicolon. This is an advanced connection method that you should use only when you know the exact syntax of all connection options that the ODBC driver requires for a successful connection.

PATH=path-for-file

specifies the data source file location for the Microsoft Access database file or Microsoft Excel workbook file.

PORT=port-number

The port or service name on the PC that the SAS PC Files Server is listening on. This port or service name is displayed on the SAS PC Files Server window when it is started on the PC. This is a required field when connecting to the PC Files Server for data.

Alias: SERVICE|SERVICE_NAME
SERVER=pc-server-host-name

specifies the computer name of the PC on which you started the PC Files Server. This name is required by UNIX users to connect to this server machine and is reflected on the server control panel. This is a required field when connecting to the PC Files Server for data.

You can specify this host name as a simple computer name (for example, wxp320), a fully qualified network name (for example, wxp320.domain.com), or an IP address.

SERVERUSER='domain\server-user-name'

specifies the domain name and User ID for the PC running PC Files Server. Always enclose the value in quotes, otherwise the backslash can be misinterpreted by the SAS parser.

Alias: SERVERUID
Note: If you are not on a domain, omit the domain name and the backslash.
Note: Use the USER= option for database User IDs.
SERVERPASS='server-user-password'

specifies the password for the PC Files Server for the User ID given. If the account has no password, omit this option. Always enclose the value in quotes in order to preserve the case of the password.

Alias: SERVERPASSWORD|SERVERPW|SERVERPWD
Note: Passwords are generally case sensitive.
Note: Use the PASSWORD= option for database passwords.
SSPI=YES|NO

enables the PC Files Server to allow Integrated Windows Authentication. This is a mechanism for the Windows client and server to exchange credentials.

Default: NO
Note: SSPI can also be enabled by specifying the -SSPI option on the SAS command line.
Restriction: Microsoft Windows 64-Bit only.
DBPASSWORD=database-password

enables you to access your file if you have database-level security set in your MDB file. A database password is case sensitive, and you can define it instead of user-level security

Note: Microsoft Access only.
DBSYSFILE=workgroup-information-file

contains information about the users in a workgroup based on information that you define for your Microsoft Access database. Any user and group accounts or passwords that you create are saved in the new workgroup information file.

PASSWORD=user-password

specifies a password for the user account, if required by the data source. Passwords are case sensitive.

MSENGINE= ACE|JET

determines the database engine used for accessing the Microsoft Excel file or Microsoft Access database. The Microsoft Jet engine is older and supports formats up to 2003. The Microsoft Ace engine supports 2007 and older formats.

Restriction: It is recommended that you do not use this file option unless you are trying to create a 95 format file.
Default: ACE
USER=User ID

specifies a default user account name. The default value is Admin. User names can be 1 to 20 characters long and can include alphabetic characters, accented characters, numbers, and spaces. If you have user-level security set in your MDB file, you need to use this option and the PASSWORD= option to access your file.

VERSION=2007 | 2003 | 2002 | 2000 | 97 | 95 | 5

sets the version of Microsoft Excel workbook. The default value is 97.

Alias: VER
Note: You do not need to specify this option for an existing Microsoft Excel file. However, if you want to create a new Microsoft Excel workbook file, you can use this option to specify the version that you want to create. Note that versions 97, 2000, and 2003 share the same file format. Versions 95 and 5 share a separate file format.
Restriction: Microsoft Excel only.

CONNECT Statement Arguments

Connect Statement arguments are supported by the Pass-Through Facility CONNECT statement for PC Files. These arguments extend some of the LIBNAME statement connection management features to the Pass-Through Facility.

AUTOCOMMIT=YES | NO

determines whether the ACCESS engine commits (saves) updates as soon as they are submitted.

YES

specifies that updates are committed (saved) to the table as soon as they are submitted. No rollback is possible.

NO

specifies that the SAS/ACCESS engine automatically performs the commit when it reaches the end of the file.

Default: YES

Note:   The default value for this option is different from the LIBNAME option.  [cautionend]

COMMAND_TIMEOUT=number-of-seconds

specifies the number of seconds before a data source command times out.

Default: 0 (no time-out)
Alias: TIMEOUT=
CONNECTION= SHARED |GLOBAL

specifies whether multiple CONNECT statements for a data source can use the same connection. The CONNECTION= option enables you to control the number of connections, and therefore transactions, that your SAS/ACCESS engine executes and supports for each CONNECT statement.

SHARED

specifies that the CONNECT statement makes one connection to the DBMS. Only pass-through statements that use this alias share the connection.

GLOBAL

specifies that multiple CONNECT statements can share the same connection to the DBMS.

  • They must use identical values for the CONNECTION= option.

  • They must use identical values for the CONNECTION_GROUP= option.

  • Database connection arguments must be identical.

Default: SHARED
CONNECTION_GROUP= connection-group

causes operations against multiple librefs to share a connection to the data source. Also causes operations against multiple Pass-Through Facility CONNECT statements to share a connection to the data source.

CURSOR_TYPE= DYNAMIC | FORWARD_ONLY | KEYSET_DRIVEN | STATIC

specifies the cursor type for read-only cursors and for cursors to be updated.

DYNAMIC

specifies that the cursor reflects all changes that are made to the rows in a result set as you move the cursor. The data values and the membership of rows in the cursor can change dynamically on each fetch. This is the default for the DB2 UNIX, PC files, and Microsoft SQL Server interfaces.

FORWARD_ONLY

specifies that the cursor behaves like a DYNAMIC cursor, except that it supports only fetching the rows sequentially.

KEYSET_DRIVEN

specifies that the cursor determines which rows belong to the result set when the cursor is opened. However, changes that are made to these rows are reflected as you scroll around the cursor.

STATIC

specifies that the complete result set is built when the cursor is opened. No changes that are made to the rows in the result set after the cursor is opened are reflected in the cursor. Static cursors are read-only.

Default: None
Alias: CURSOR=
DBGEN_NAME=DBMS | SAS

specifies that the data source columns are renamed, and specifies the format that the new names follow.

DBMS

specifies that the data source columns are renamed to valid SAS variable names. Disallowed characters are converted to underscores. If a column is converted to a name that already exists, then a sequence number is appended to the end of the new name.

SAS

specifies that data source columns are renamed to the format _COLn, where n is the column number (starting with zero).

Default: DBMS
DBMAX_TEXT=n

specifies an integer between 1 and 32,767 that indicates the maximum length for a character string. Longer character strings are truncated. This option applies only when you are reading, appending, and updating Microsoft Access or Excel character data from SAS.

Note:   Although you can specify a value less than 256, it is not recommended.  [cautionend]

Default: 1,024
DEFER=NO | YES

enables you to specify when the CONNECT statement occurs.

NO

specifies that the connection to the data source occurs when the libref is assigned by a LIBNAME statement.

YES

specifies that the connection to the data source occurs when a table in the data source is opened.

Default: NO
READBUFF=number-of-rows

specifies the number of rows to use when you are reading data from a data source. Setting a higher value for this option reduces I/O and increases performance, but also increases memory usage. Additionally, if too many rows are read at once, values returned to SAS might be out of date.

Default: 1
Alias: ROWSET=

ROWSET_SIZE=

STRINGDATES=YES | NO

specifies whether datetime values are read from the data source as character strings or as numeric date values. STRINGDATES= is not available as a data set option.

YES

specifies that SAS/ACCESS reads datetime values as character strings.

NO

specifies that SAS/ACCESS reads datetime values as numeric date values.

Default: NO
Alias: STRDATES

Details

The CONNECT statement establishes a connection with the data source. You establish a connection to send data source-specific SQL statements to the data source or to retrieve data source data. The connection remains in effect until you issue a DISCONNECT statement or terminate the SQL procedure. See: DISCONNECT Statement .

To connect to a data source using the Pass-Through Facility, complete the following steps:

  1. Initiate a PROC SQL step.

  2. Use the Pass-Through Facility CONNECT statement with the PC files engine name and then assign an alias if you want.

  3. Specify any arguments needed to connect to the database.

  4. Specify any attributes for the connection.

The CONNECT statement is optional for some data sources. However, if you do not specify it, default values for all database connection arguments are used.

Any return code or message that is generated by the data source is available in the macro variables SQLXRC and SQLXMSG after the statement executes. See Return Codes for more information about these macro variables.


Example

The following example uses the CONNECT statement with the PATH= option to connect to the Microsoft Access database file, c:\demo.mdb:

PROC SQL;
CONNECT TO PCFILES AS db (SERVER=d2323 PATH=' c:\demo.mdb' );

Previous Page | Next Page | Top of Page