使用 sas 数据集中的值在数据库中创建临时表

发布于 2024-12-26 10:12:51 字数 512 浏览 2 评论 0原文

任何人都可以帮助我使用 SAS 数据集中的值在数据库中创建临时表的语法吗?我想接下来使用这个临时表来与数据库中的其他表连接。

libname X odbc dsn=aaabbb uid=abcd pwd=efgh quote_char=''; 

data X.vishtest;   
set test.noosbtest; 
run; 

我想使用 SAS 数据集“test.noosbtest”中的值创建“vishtest”作为临时表。

我在之前的尝试中创建了一个临时表,如下所示并删除其中的值,但接下来我无法将 sas 数据集的值放入此临时表中:

select * from connection to X(Create temp table vishtest as select var1 from table1 limit 20); 

select * from connection to X(delete from tempdb.vishwatemp a);

can anyone help me with the syntax of creating a temp table in a database with the values from a SAS data set ? I want to use this temp table next to join with other tables in the database.

libname X odbc dsn=aaabbb uid=abcd pwd=efgh quote_char=''; 

data X.vishtest;   
set test.noosbtest; 
run; 

I want to create 'vishtest' as a temp table with the values in a SAS data set 'test.noosbtest'.

I have created a temp table in an earlier attempt like the following and deleting the values in it, but next I am unable to put the values of sas data set into this temp table :

select * from connection to X(Create temp table vishtest as select var1 from table1 limit 20); 

select * from connection to X(delete from tempdb.vishwatemp a);

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

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

发布评论

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

评论(1

听风吹 2025-01-02 10:12:51

您必须确保本地 sas 数据集与数据库表具有相同的列。

如果您现有的数据库表是 X.my_table 并且您的本地数据集是 mylib.the_data,您可以尝试以下操作:

proc sql;
    create table X.my_table_empty like X.my_table;
    create table the_data_empty like mylib.the_data;
quit;
proc compare
    data = my_table_empty
    compare = the_data_empty;
run;

如果 proc Compare 返回并告诉您这两个表是相同的,那么您应该能够将数据表加载到临时表:

proc append
    base = X.my_table_empty
    data = mylib.the_data;
run;

原答案:

<块引用>
<块引用>

这是从另一个现有表创建临时表 vishtest
有大约 20 行数据,我正在删除 temp 的内容
表维什测试。到这里为止一切正常...但是接下来,我想输入
来自我本地的 SAS 数据集的此临时表的值
驱动器或库,我无法做到

如果 vishtest 包含与您的 sas 数据集相同的列,则此
可能适合你:

proc 追加
    基础 = X.vishtest
    数据=测试.noosbtest;
跑步;

You have to make sure that your local sas data set has the same columns as your database table.

If your existing database table is X.my_table and your local dataset is mylib.the_data, you can try this:

proc sql;
    create table X.my_table_empty like X.my_table;
    create table the_data_empty like mylib.the_data;
quit;
proc compare
    data = my_table_empty
    compare = the_data_empty;
run;

If proc compare comes back and tells you that the two tables are identical, then you should be able to load your data table into the temp table:

proc append
    base = X.my_table_empty
    data = mylib.the_data;
run;

Original answer:

This is creating a temp table vishtest from another existing table
with some 20 rows of data and I am deleting the contents of the temp
table vishtest. It works fine till here...but next,I want to input
values to this temp table from a SAS data set which is on my local
drive or lib, which I am unable to do

If vishtest contains the same columns as your sas dataset, then this
may work for you:

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