SAS 到 Oracle ODBC - 将 SAS 表传入数据库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1316609/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 18:51:09  来源:igfitidea点击:

SAS to Oracle ODBC - passing a SAS table INTO the database

oracleodbcsasproc-sql

提问by Allan Bowe

Can anyone please advise the syntax for passing a table FROM a SAS library INTO an oracle database?

任何人都可以建议将表从 SAS 库传递到 oracle 数据库的语法吗?

example code below (although obviously the connection to the WORK library cannot be referenced in this way)

下面的示例代码(虽然显然不能以这种方式引用到 WORK 库的连接)

PROC SQL noprint;
connect to ODBC as X (dsn='ALIAS' uid='USER1' pwd='passwd' quote_char='');
exec (CREATE TABLE Test AS
    SELECT * from WORK.MY_SAS_TABLE
    )by X;
disconnect from X;
quit;

A similar question was asked herebut seems to relate to a SQLSERVER connection rather than oracle..

在这里一个类似的问题,但似乎与 SQLSERVER 连接而不是 oracle 相关。

回答by Simon Nickerson

Set up a libref to point to your Oracle database, either using the ODBC libname engine or the Oracle libname engine (which will be faster if you have the right licence and software installed):

使用 ODBC libname 引擎或 Oracle libname 引擎(如果安装了正确的许可证和软件,速度会更快)设置一个 libref 以指向您的 Oracle 数据库:

libname X oracle username='USER1' password='passwd' path=ORCL;

If an empty table with the right columns already exists in Oracle, you can use:

如果 Oracle 中已经存在具有正确列的空表,则可以使用:

proc sql noprint;
  insert into X.test select * from work.my_sas_table;
quit;

If the table doesn't exist, you can use a data step:

如果表不存在,您可以使用数据步骤:


data X.test;
  set work.my_sas_table;
run;

回答by John Fouhy

I'm a bit rusty, but what if you set up your database as a libref?

我有点生疏,但是如果您将数据库设置为 libref 呢?

Something like:

就像是:

libname X odbc dsn='ALIAS' uid='USER1' pwd='passwd' quote_char='';
data X.test;
    set work.my_sas_table;
run;