使用 SAS 代码使用 SAS 数据集中的数据更新 Oracle 表

发布于 2024-09-12 04:05:57 字数 398 浏览 11 评论 0原文

我对 SAS 相当陌生,我遇到了一个问题,我认为可能有比我迄今为止发现的更好的解决方案。

我需要使用包含约 10,000 条记录的 SAS 数据集的数据来更新包含约 100 万行的 Oracle 数据库表。

我在 proc sql 中使用了更新语句,但更新 Oracle 表需要几个小时。现在,我正在将 SAS 数据集中的数据加载到 Oracle 数据库中的临时表中,并执行 proc sql 传递执行语句以从临时表更新主表。这最多只需要几分钟。

然而,这对于编程来说相当麻烦,而且我需要从 SAS 代码中的多个函数更新 Oracle 表。

SAS中有没有类似于JDBC批量更新的东西(我在接触SAS之前经常做Java编程)?比在 proc sql 中使用更新语句更快,但比临时表 + 使用传递更新更容易编码的东西?

I am rather new to SAS and I have run into a problem that I think probably has a better solution than what I've found so far.

I need to update a Oracle db table that has around 1 million rows with data from a SAS data set that has about 10,000 records.

I used an update statement within proc sql, but it takes hours to update the Oracle table. Right now, I am loading the data from the SAS data set into a temporary table in the Oracle db and doing a proc sql pass through execute statement to update the main table from the temporary table. This takes only a couple of minutes at most.

However, this is rather cumbersome to program and and I need to update the Oracle table from multiple functions within my SAS code.

Is there an analog to JDBC batch update in SAS (I uses to do Java programming before getting involved in SAS)? Something that is faster than using an update statement in proc sql, but easier to code than temp table + update using pass through?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我的影子我的梦 2024-09-19 04:05:57

您是否使用 SAS/Access 将 SAS 会话连接到 Oracle?

在我的情况下,我使用 SAS/Connect JDBC。

SAS/Connect 是将 SAS 基底系统连接到 JEE 的一种非常简单但有效的策略。本质上 sas/connect 是 sas 执行 sas -dmr 的另一个 telnet 实现。

我使用 sas/connect jdbc 将 sas 数据提取到 jsp 中,然后使用我们都熟悉的 java 编程技术将数据推送到 oracle 或 sql server。

阅读我关于使用 sas/connect 将 sas 连接到 JEE 的古老论文:
http://www.nesug.org/proceedings/nesug04/ap/ap02。 pdf
顺便说一句,不要尝试通过纸上列出的联系人与我联系 - 他们已经很古老了。

回应您的进一步陈述

我以为您想要一种使用 JDBC 将数据插入 Oracle 的方法?
我的论文向您展示了如何在 JSP 中嵌入整个 SAS 宏或 SQL 块或任何文本,然后提交该文本块以通过 SAS/Connect 运行。

String datasetname = request.getParameter("datasetname");
String where = request.getParameter("where");

<t:text id="macHello">
%macro hello(datasetname);
 data &datasetname;
 /* code to create your data */
 run;
%mend;

%hello(<%=datasetname%>);
</t:text>

sasConnect.submit(macHello);

<t:text id="SQLgetRecs">
 SELECT *
 FROM <%=datasetname%>
 WHERE <%=where%>
</t:text>

ResultSet mydata =
sasConnJDBC.executeQuery(SQLgetRecs);

然后用 Java 做任何你需要做的事情,
通过在 Oracle 每次迭代结果集时交织插入
或迭代结果集以生成 SQL 插入 VALUES 的文本块
然后将其提交给 Oracle JDBC。

如果您知道如何使用 JSP 并且愿意了解我编写的文本块标记库如何工作,那么它只是一个 JSP。您会看到,我使用此技术允许 JSP 运行已在生产批处理模式下运行多年的 SAS 宏,而无需对宏进行任何更改。不仅如此,标签库还允许我将 java 和 jsp 变量解析嵌入到宏或 sas/sql 块中。

我编写这个块文本标签库是因为我曾经在 Perl 中执行此类操作(2003 年之前),其中 Perl(和其他脚本语言)允许您将变量分配给脚本代码中的连续文本块。

使用标签库的说明:

http://h2g2java.blessedgeek .com/2009/07/jsp-text-custom-tag.html

http://h2g2java.blessedgeek.com/2009/07/referencing-text-jsp-custom-tag-define.html

Are you using SAS/Access to connect your SAS sessions to Oracle?

In my situation, I use SAS/Connect JDBC.

SAS/Connect is a very simple but effective strategy for interfacing the SAS substrate system to JEE. Essentially sas/connect is yet another telnet implementation by sas to execute sas -dmr.

I draw the sas data out using sas/connect jdbc into my jsp and then push the data into oracle or sql server using java programming techniques we are all familiar with.

Read my ancient paper on using sas/connect to connect sas to JEE:
http://www.nesug.org/proceedings/nesug04/ap/ap02.pdf.
BTW do not try to contact me with the contacts listed on the paper - they are ancient.

In response to your further statement:

I thought you wanted a way to use JDBC to insert the data into Oracle?
My paper shows you how to embed a whole block of SAS macro or SQL or any text in a JSP and then submit that block of text to be run through SAS/Connect.

String datasetname = request.getParameter("datasetname");
String where = request.getParameter("where");

<t:text id="macHello">
%macro hello(datasetname);
 data &datasetname;
 /* code to create your data */
 run;
%mend;

%hello(<%=datasetname%>);
</t:text>

sasConnect.submit(macHello);

<t:text id="SQLgetRecs">
 SELECT *
 FROM <%=datasetname%>
 WHERE <%=where%>
</t:text>

ResultSet mydata =
sasConnJDBC.executeQuery(SQLgetRecs);

Then do whatever you need to do with Java,
either by interweaving insertion in Oracle per iteration of Resultset
or iterate resultset to produce a text block of SQL insert VALUES
which you then submit to Oracle JDBC.

It would just be a single JSP, provided you know how to work a JSP and willing to understand how the text-block tag library I wrote works. You see, I use this technique to allow a JSP run SAS macros that have been running in production batch mode for ages, without any change to the macros. Not only so, the tag lib allows me to embed java and jsp variable resolution into the macros or sas/sql blocks.

I wrote this block-text tag lib because I used to do such operations in Perl (prior to 2003), where Perl (and other scripting languages) allows you to assign a variable to a continuous block of text within the code of the script.

Instructions on using the tag lib:

http://h2g2java.blessedgeek.com/2009/07/jsp-text-custom-tag.html

http://h2g2java.blessedgeek.com/2009/07/referencing-text-jsp-custom-tag-defined.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文