• Print  |
  • Feedback  |

Knowledge Base


TS-627

Connecting to Sybase from SAS on WINNT or WIN95

Connecting to Sybase from SAS on WINNT or WIN95.

Using SAS/ACCESS Interface to Sybase.

In order to use SAS/Access Interface to Sybase on PC, it's required that you have Base SAS, SAS/Access Interface to Sybase and Sybase Open Client for Windows installed. The Open Client software must be installed on the same PC where the SAS/Access Interface will be used. To verify that SAS/Access Interface to Sybase is installed, look in the !sasroot\access\sasexe subdirectory for a file called SASIOSYB.DLL. Note: In order to use Sybase 11 open client with SAS/Access Interface to Sybase 6.12 TS020 - TS055, you must download the updated support modules.

http://support.sas.com/techsup/pc/syb11fix.zip

Example of reading Sybase data into SAS.

/* The values that you specify for the USER=, SERVER=, DATABASE=, PASSWORD=, TABLE= statements are the same as you would use to connect to Sybase directly using Open Client. See your database administrator to determine the databases that have been setup in your operating system */

PROC ACCESS dbms=sybase;

Create work.employee.access;

Server='Sybase11'

Database='users';

User='dbitest';

Password='password'

Table='test1';

Create sasuser.employee.view;

Run;

In Version 7 and higher, you no longer need to create access and view descriptors. You can use Libname statement with Sybase engine.

Libname syblib sybase user=dbitest password=xxxxx server=sybase11;

After a SAS library is assigned, the DBMS connection can be used by the SAS System to get a list of Sybase Tables and Views with Datasets procedure.

PROC datasets lib=syblib;

run;

Example of Using SAS/Access Interface to Sybase to write SAS Dataset into Sybase table.

DBLOAD dbms=syabse data=sasuser.employee;

Server='Sybase11';

Database='users'

User='dbitest'

Table=testnew;

Load;

Run;

Example of using SAS/Access Interface to Sybase ODBC and Sybase open client to read Sybase table into a SAS Dataset.

Options SET=SYBBRGNM sassyb11;/* use when both clients installed - must download syb11fix.zip */

PROC SQL;

Connect to sybase (user='dbitest' password='xxxxx' server='sybase11' database='users');

Create table work.test as

Select * from connection to sybase (select * from KGTEST1);

Disconnect from sybase;

Quit;

2 Using SAS/ACCESS Interface to ODBC

In order to use SAS/Access Interface to ODBC on PC, it's required that you have Base SAS,SAS/Access Interface to ODBC software and also the ODBC driver from Sybase installed on the same PC where the SAS/Access to ODBC will be used. To verify that SAS/Access Interface to ODBC is installed, look in the
!sasroot\acccess\sasexe subdirectory for a file called SASIOODB.DLL.

This product uses PROC SQL pass-through statements.

Example of using SAS/Access Interface to ODBC and Sybase ODBC Driver to read Sybase table into SAS.

PROC SQL;

Connect to odbc(dsn='Sybase11' uid='dbitest' pwd='xxxxx');

Create table work test as

Select * from connection to odbc(select * from KGTEST1);

Disconnect from odbc;

Quit;

In Version 7 and higher, you can use Libname statement with ODBC engine. Once the libname is assigned successfully, the Sybase table and view can be accessed by using the libref as if it were a SAS Dataset.

Example of using Libname with SAS/Access Interface to ODBC.

Libname syodbc odbc dsn='sybase' uid='dbitest' pwd='xxxxx';

In Version 7 and higher you can also use PROC DBLOAD using SAS/Access to ODBC to write SAS Dataset into Sybase Table

PROC DBLOAD dbms=odbc data=mylib.dept;

DSN='Sybase';

Uid='dbitest';

Pwd='xxxx'

Table='newdept'

Limit=0;

Load;

Run;