Previous Page | Next Page

LIBNAME Statement and Pass-Through Facility for PC Files on Microsoft Windows

CONNECTION TO Component



Retrieves and uses data source data in a PROC SQL query or view.
Valid in: PROC SQL step SELECT statements

Syntax
Arguments
Details
Example

Syntax

CONNECTION TO data-source-name<AS alias><(database-connection-options)>


Arguments

data-source-name

identifies the data source (Microsoft Access or Excel) to which you direct the data source-specific SQL statement.

alias

specifies an alias, if one was defined in the CONNECT statement.

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 and the default behavior opens a dialog box.


Details

The CONNECTION TO component specifies the data source connection that you want to use or that you want to create (if you have omitted the CONNECT statement). CONNECTION TO then enables you to retrieve data source data directly through a PROC SQL query.

You use the CONNECTION TO component in the FROM clause of a PROC SQL SELECT statement:

SELECT column-list
FROM CONNECTION TO data source-name (data source-query);

CONNECTION TO can be used in any FROM clause, including those in nested queries (that is, in subqueries).

You can store a Pass-Through Facility query in a PROC SQL view and then use that view in SAS programs. When you create a PROC SQL view, any options that you specify in the corresponding CONNECT statement are stored too. Thus, when the PROC SQL view is used in a SAS program, SAS can establish the appropriate connection to the data source.

Because external data sources and SAS have different naming conventions, some data source column names might be changed when you retrieve data source data through the CONNECTION TO component.

Note:   You must use back quotes ( ` ), not single (' ) or double quotes (" ), to enclose names that contain a space.  [cautionend]


Example

Use the CONNECTION TO component to query a table or a subtable after the connection

SELECT * FROM CONNECTION TO db(SELECT * FROM `my invoice`);
SELECT * FROM CONNECTION TO db
(SELECT `Invoice Number`, Amount from `my invoice`);

Previous Page | Next Page | Top of Page