SAS Proc SQL 数据库表插入 [英] SAS Proc SQL Database Table Insert

查看:19
本文介绍了SAS Proc SQL 数据库表插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 SAS 的 Proc SQL,有没有办法将 SAS 数据集中的记录插入到打开的 SQL Server 连接中的表中?像这样的东西(不起作用):

Using SAS's Proc SQL, is there a way to insert records from a SAS Dataset into a table in the open SQL Server connection? Something like this (which doesn't work):

proc sql exec;
    connect to sqlservr as DataSrc (server=my-db-srvr database=SasProcSqlTest);

    create table Items as select * from connection to DataSrc (
        SELECT * FROM tblItem
    );

    update Items
    set Name = Name + Name,
        Value * 2;

    insert into tblItem (Name, Value)
    select Name, Value
    from Items;

    disconnect from DataSrc;quit;run;
quit;
run;

推荐答案

据我所知,使用 SQL 传递会将您限制在数据库服务器上.SAS 文档说您最好创建对数据库的库引用,然后将数据库表视为 SAS 表.在您的情况下,这意味着只是普通的 proc sql.这至少在最新的 SAS 版本中应该可以工作,但对于大型表来说并不是最佳选择.

To my knowledge, using pass through SQL constrains you to the database server. The SAS documentantion says that you should preferrably create a library reference to the database and then treat the database tables just like SAS tables. In your case this means just normal proc sql. This should work at least in the latest SAS versions, but for large tables is not optimal.

我们为避免这种情况所做的是

What we've done to circumvent this is

  1. 在临时数据库中创建表 - 该表不应是特定于会话的
  2. 使用 proc append 将数据从 SAS 批量加载到创建的表中
  3. 进行传递更新
  4. 删除临时数据库中的表.

这篇关于SAS Proc SQL 数据库表插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆