Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

SAS Access / SAS Connect

7,283 views

Published on

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

Published in: Technology, Business
  • Be the first to comment

SAS Access / SAS Connect

  1. 1. SAS Techies [email_address] http://www.sastechies.com
  2. 2. <ul><li>Reading and Writing data to Other DBMS’s </li></ul><ul><ul><li>SAS Access Libname Method </li></ul></ul><ul><ul><li>SAS Connect Pass Thru SQL ( RSPT ) </li></ul></ul><ul><ul><li>Proc Dbload / Proc Access </li></ul></ul><ul><ul><li>Which one to Choose and when ?? </li></ul></ul>11/13/09 SAS Techies 2009
  3. 3. <ul><li>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. </li></ul>SAS Techies 2009 LIBNAME libref oracle <connection-options> <LIBNAME-options>; DBCOMMIT=n PRESERVE_COL_NAMES= NO | YES PRESERVE_TAB_NAMES= NO | YES
  4. 4. <ul><li>libname orcl oracle user=scott password=tiger path=&quot;ORCL&quot;; </li></ul><ul><li>Options sastrace=‘,,,d’; </li></ul><ul><li>data orcl.admit; </li></ul><ul><li>input x y; </li></ul><ul><li>cards; </li></ul><ul><li>1 2 </li></ul><ul><li>3 4 </li></ul><ul><li>5 6 </li></ul><ul><li>; </li></ul><ul><li>run ; </li></ul><ul><li>data orcl.ap; </li></ul><ul><li>set perm.airports; </li></ul><ul><li>run ; </li></ul><ul><li>Proc sql; </li></ul><ul><li>Create table orcl.ap as </li></ul><ul><li>Select * from perm.airports; </li></ul><ul><li>Quit; </li></ul><ul><li>Proc sql ; </li></ul><ul><li>Create table orcl.ap1 as </li></ul><ul><li>Select * from perm.admitjune A, perm.admit B </li></ul><ul><li>Where A.id=B.id; </li></ul><ul><li>Quit; </li></ul><ul><li>libname orcl db2 user=scott password=tiger path=“DB2&quot;; </li></ul><ul><li>Proc sql; </li></ul><ul><li>Create table orcl.ap1 as </li></ul><ul><li>Select * from orcl.ap A, db2.ap B </li></ul><ul><li>Where A.id=B.id; </li></ul><ul><li>Quit; </li></ul>11/13/09 SAS Techies 2009
  5. 5. <ul><li>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. </li></ul>SAS Techies 2009
  6. 6. <ul><li>Creating SAS dataset from DBMS table </li></ul><ul><li>proc sql ; </li></ul><ul><li>connect to oracle (user=scott password=tiger path=&quot;ORCL&quot;); </li></ul><ul><li>create table work.cool as </li></ul><ul><li>select * from connection to oracle </li></ul><ul><li>(select A.* </li></ul><ul><li>from info A, descr B </li></ul><ul><li>where A.FlightID=B.FlightID ); </li></ul><ul><li>disconnect from oracle; </li></ul><ul><li>quit; </li></ul><ul><li>Creating a DBMS table from two DBMS tables </li></ul><ul><li>proc sql ; </li></ul><ul><li>connect to oracle (user=scott password=tiger path=&quot;ORCL&quot;); </li></ul><ul><li>execute( create table Sharad as </li></ul><ul><li>select A.* </li></ul><ul><li>from info A, descr B </li></ul><ul><li>where A.FlightID=B.FlightID ) by oracle; </li></ul><ul><li>execute( COMMIT ) by oracle; </li></ul><ul><li>disconnect from oracle; </li></ul><ul><li>quit; </li></ul>11/13/09 SAS Techies 2009
  7. 7. <ul><li>proc dbload dbms=oracle </li></ul><ul><li>data=perm.admit; *SAS dataset; </li></ul><ul><li>user=scott; </li></ul><ul><li>password=tiger; </li></ul><ul><li>path='ORCL'; </li></ul><ul><li>table=newemp; *DBMS Table; </li></ul><ul><li>commit= 100 ; </li></ul><ul><li>errlimit= 10 ; </li></ul><ul><li>load; run ; </li></ul><ul><li>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. </li></ul>SAS Techies 2009
  8. 8. 11/13/09 SAS Techies 2009
  9. 9. 11/13/09 SAS Techies 2009
  10. 10. <ul><li>Usually the fastest and most direct method.. An exception to this is when you need to use non-ANSI standard SQL. </li></ul><ul><li>Only way to Join data on Two different DBMS. </li></ul><ul><li>Significantly fewer lines of SAS code. </li></ul><ul><li>You do not need to know the SQL language of your DBMS. </li></ul><ul><li>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. </li></ul><ul><li>The engine can optimize the processing of joins and WHERE clauses by passing these operations directly to the DBMS. </li></ul><ul><li>The engine can pass some functions directly to the DBMS for processing. </li></ul><ul><li>Pass-Through Facility statements enable the DBMS to optimize queries, particularly when you join tables. </li></ul><ul><li>The DBMS optimizer can take advantage of indexes on DBMS columns to process a query more quickly and efficiently. </li></ul><ul><li>Pass-Through Facility statements enable the DBMS to optimize queries when the queries have summary functions. </li></ul><ul><li>Pass-Through Facility statements give you better access to DBMS return codes. </li></ul><ul><li>The Pass-Through Facility accepts all the extensions to ANSI SQL that are provided by your DBMS </li></ul>11/13/09 SAS Techies 2009

×