SAS Proc SQL 数据库表插入
使用 SAS 的 Proc SQL,有没有办法将 SAS 数据集中的记录插入到打开的 SQL Server 连接中的表中? 像这样的东西(不起作用):
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;
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;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,使用 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
您可以在打开的连接中执行您想要的操作..
创建关联的 libname..
上面的伪代码应该让您了解它应该如何工作。 您可能还需要在 proc sql 中创建“some_temp_table”或者有一个可用的永久临时表。
You can do what you want within an open connection..
create an associated libname..
The above pseudo code should give you an idea of how it should work. You may need to create the "some_temp_table" in the proc sql as well or have a permanent staging table available.