[Reserved] [SAS and common database connection code finishing]

zhaozj2021-02-16  48

/ ************************************************** ******************

Function: Link SQL Server Database

Parameter Description:

Libname (Database Name of SAS) Data Source (SQL Server Host Address)

Initial Catalog (SQL Server Database Name)

User ID (SQL Server Database Login User Name) Password (SQL Server Database Login Password)

*********************************************************** ***************** /

/ * Connect DatabaseName Database * /

LibName Base Oledb Provider = SQLOLDB

Properties = ("Data Source" = ServerName "User ID" = myusername "password" = mypassword "initial catalog" = databasename);

/ ************************************************** ******************

Function: Link Oralce Database

Parameter Description:

Libname (Database Name) Path (Oracle Database SID)

Schema (Oralce Database Name is generally a database)

Oracle User (Oracle Database Login User Name) Password (Oracle Database Login Password)

Note: The account password logging in to the Oracle database must have permission to log in to the specified database

*********************************************************** ***************** /

/ * Link DatabaseName Database (SID: ORCL) * /

LibName DatabaseName Oracle User = myusername password = mypassword path = 'orcl' schema = databasename;

/ ************************************************** ******************

Function: Link DBF Data File

Parameter Description:

FILENAME (specified DBF file you want to open)

DB5 (2, 3, 4, 5) Specify the version of DBASE)

OUT (recordset in SAS)

*********************************************************** ***************** /

FileName DatabaseName 'Disk: / Path / File Name .dbf';

Proc DBF DB5 = DatabaseName Out = DatabaseName;

Run;

/ ************************************************** ******************

Function: Import Excel Data File

Parameter Description:

OUT (output SAS dataset)

DataFile (Specify imported Excel file) Range (specify the imported Sheet name)

GetNames (first tomb)

*********************************************************** ***************** /

Proc import out = work.databaseName

DataFile = "Drive: / Path / File Name .xls"

DBMS = EXCEL2000 Replace;

Range = "Sheet1 $";

GetNames = YES;

Run;

/ ************************************************** ******************

Function: Import Access Data File

Parameter Description:

OUT (output SAS dataset)

DataFile (Specify the imported Access data sheet)

Database (Access Database File)

*********************************************************** ***************** /

Proc import out = work.tablename

DataTable = "TableName"

DBMS = Access2000 Replace;

Database = "Drive: / Path / File Name .mdb";

Run;

转载请注明原文地址:https://www.9cbs.com/read-20294.html

New Post(0)