Communication between SAS and DBMS (sqlserver)

Source: Internet
Author: User

1 Use oledb

Code description: library copy the testtable table to the local SAS work logical database

Libname mydb oledb init_string = " Provider = sqloledb.1; Password = ******; persist Security info = true; user id = sa; initial catalog = testdb; Data Source = 192.168.0.3 " ;

Data testtable;

Set Mydb. testtable;

Run;

Proc print;

Run;

2 use odbc engine

Code Description: Replace the testdb data on the 192.168.0.3 ServerLibraryCopy the testtable table to the work logical database of the local SAS.

First, create ODBC Engine" Sastest "

Libname mydb ODBC uid = Sa pwd = ****** Database = Testdb DSN = Sastest;

Data testtable;

Set Mydb. testtable;

Run;

Proc print;

Run;

3Database link wizard

Code Description: Open the database link wizard

Libname mylib oledb;

% Put & Sysdbmsg ;( % Put % Superq (sysdbmsg); sasv9 is better)

Data bpsas;

Set Mylib. BP;

Run;

Proc print;

Run;

4 Link SQL Server Use NT Verify

Code Description: Set Sashelp. Class Table upload SQL Server Upper

Libname x oledb provider = Sqloledb DSN = ' Sastest ' Properties = ( " Integrated Security " = Sspi " Persist Security info " = True

" Initial catalog " = Northwind );

Proc SQL;

Create Table X. Class As Select * From sashelp. Class Where Age > 10 ;

Quit;

5 Call database Stored Procedures

LReturned value. Stored Procedure name: usp_who

Proc SQL;

Connect to oledb (DSN = ' Sastest ' UID = As PWD = ****** Provider = Sqloledb );

Select * From connection to oledb (usp_who );

Quit;

L Stored Procedure name without return value: sp_rename Proc SQL;

Connect to oledb (DSN = ' Sastest ' UID = As PWD = ****** Provider = Sqloledb );

Execute (sp_rename " Badcrime " , " Barbcrime " ) By oledb;

Quit;

6 accessing OLAP data (Access Online Analytical Processing Data) Proc SQL;

Connect to oledb (provider = Msolap props = ( ' Initial catalog ' = ' Foodsmart 2000 '

' Data Source ' = ' Dwtsrv1 ' ));

Select * From connection to oledb

(MDX: select non empty {[Time]. [1997], [Time]. [1998]} On columns, non

Empty {[Account]. [all account]} On rows from [budget] Where ([category].

[All category], [measures]. [amount], [store]. [All stores]);

Quit;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.