LIBNAME Statement and Pass-Through Facility for PC Files on Microsoft Windows |
Valid in: | PROC SQL step SELECT statements |
Syntax | |
Arguments | |
Details | |
Example |
Syntax |
CONNECTION TO data-source-name<AS alias><(database-connection-options)> |
Arguments |
identifies the data source (Microsoft Access or Excel) to which you direct the data source-specific SQL statement.
specifies an alias, if one was defined in the CONNECT statement.
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
|
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.
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`);
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.