sas slides 14 : sas access / sas connect

10
SAS Techies [email protected] http://www.sastechies.com

Upload: sastechies

Post on 16-Nov-2014

6.176 views

Category:

Documents


12 download

DESCRIPTION

Learning Base SAS,Advanced SAS,Proc SQl, ODS, SAS in financial industry,Clinical trials, SAS Macros,SAS BI,SAS on Unix,SAS on Mainframe,SAS interview Questions and Answers,SAS Tips and Techniques,SAS Resources,SAS Certification questions...visit http://sastechies.blogspot.com

TRANSCRIPT

Page 1: SAS Slides 14 : SAS Access / SAS Connect

SAS [email protected]

http://www.sastechies.com

Page 2: SAS Slides 14 : SAS Access / SAS Connect

Reading and Writing data to Other DBMS’s

◦ SAS Access Libname Method◦ SAS Connect Pass Thru SQL (RSPT)◦ Proc Dbload / Proc Access◦ Which one to Choose and when ??

204/08/23SAS Techies 2009

Page 3: SAS Slides 14 : SAS Access / SAS Connect

LIBNAME libref oracle <connection-options> <LIBNAME-options>;

DBCOMMIT=n PRESERVE_COL_NAMES=NO | YES PRESERVE_TAB_NAMES=NO | YES

The LIBNAME statement enables you to assign SAS librefs to DBMS objects such as schemas and databases. After a database is associated with a libref, you can use a SAS two-level name to specify any table or view in the database and then work with the table or view as you would with a SAS data set.

3SAS Techies 2009

Page 4: SAS Slides 14 : SAS Access / SAS Connect

libname orcl oracle user=scott password=tiger path="ORCL";

Options sastrace=‘,,,d’;

data orcl.admit;input x y;cards;1 23 45 6;run;

data orcl.ap;set perm.airports;

run;

Proc sql;Create table orcl.ap asSelect * from perm.airports;Quit;

Proc sql;Create table orcl.ap1 asSelect * from perm.admitjune A,

perm.admit BWhere A.id=B.id;Quit;

libname orcl db2 user=scott password=tiger path=“DB2";

Proc sql;Create table orcl.ap1 asSelect * from orcl.ap A, db2.ap BWhere A.id=B.id;Quit;

04/08/23 4SAS Techies 2009

Page 5: SAS Slides 14 : SAS Access / SAS Connect

The Pass-Through Facility enables you to interact with a data source using its native SQL syntax without leaving your SAS session. The SQL statements are passed directly to the data source for processing.

5SAS Techies 2009

Page 6: SAS Slides 14 : SAS Access / SAS Connect

Creating SAS dataset from DBMS table

proc sql;connect to oracle (user=scott

password=tiger path="ORCL");create table work.cool asselect * from connection to oracle(select A.* from info A, descr Bwhere A.FlightID=B.FlightID );disconnect from oracle;quit;

Creating a DBMS table from two DBMS tables

proc sql;connect to oracle (user=scott

password=tiger path="ORCL");execute(create table Sharad as select A.* from info A, descr B where A.FlightID=B.FlightID) by

oracle;execute(COMMIT) by oracle;disconnect from oracle;quit;

04/08/23 6SAS Techies 2009

Page 7: SAS Slides 14 : SAS Access / SAS Connect

proc dbload dbms=oracle data=perm.admit; *SAS dataset;user=scott; password=tiger; path='ORCL'; table=newemp; *DBMS Table;commit=100; errlimit=10; load; run;

The ACCESS and DBLOAD procedures support indirect access to DBMS data. These procedures are no longer the recommended method for accessing DBMS data, but they continue to be supported for the database systems and environments on which they were available for SAS Version 6.

7SAS Techies 2009

Page 8: SAS Slides 14 : SAS Access / SAS Connect

04/08/23 8SAS Techies 2009

Page 9: SAS Slides 14 : SAS Access / SAS Connect

04/08/23 9SAS Techies 2009

Page 10: SAS Slides 14 : SAS Access / SAS Connect

Usually the fastest and most direct method.. An exception to this is when you need to use non-ANSI standard SQL.

Only way to Join data on Two different DBMS.

Significantly fewer lines of SAS code.

You do not need to know the SQL language of your DBMS.

The LIBNAME statement provides more control over DBMS operations such as locking, spooling, and data type conversion through the use of LIBNAME and data set options.

The engine can optimize the processing of joins and WHERE clauses by passing these operations directly to the DBMS.

The engine can pass some functions directly to the DBMS for processing.

Pass-Through Facility statements enable the DBMS to optimize queries, particularly when you join tables.

The DBMS optimizer can take advantage of indexes on DBMS columns to process a query more quickly and efficiently.

Pass-Through Facility statements enable the DBMS to optimize queries when the queries have summary functions.

Pass-Through Facility statements give you better access to DBMS return codes.

The Pass-Through Facility accepts all the extensions to ANSI SQL that are provided by your DBMS

04/08/23 10SAS Techies 2009