【问题标题】:How to insert only new ( not duplicate ) row to the existing table - in proc sql - sas?如何仅将新(不重复)行插入到现有表中 - 在 proc sql - sas 中?
【发布时间】:2012-04-17 16:34:34
【问题描述】:

有谁知道如何在 SAS PROC SQL 中仅向现有表插入“新”行?

proc sql;
 create table class as 
 select * 
 from sashelp.class 
 where sex = 'F'; 
quit;

proc sql;  
 create table classm as 
 select * 
 from sashelp.class 
 where sex = 'M' or Name = 'Alice';
quit;

proc sql;
 insert into class 
 select * 
 from classm ;
quit;

insert 语句不允许我使用 where 语句从 classm 中仅插入 10 个新行(没有 Alice)

有没有办法解决这个问题?因为我正在处理大数据,所以我想在 proc sql 中执行此操作,或者数据步骤很好。

谢谢

【问题讨论】:

标签: insert duplicates sas


【解决方案1】:

这对我有用...

proc sql;
create table class as 
select * 
from sashelp.class 
where sex = 'F'; 
quit;

proc sql;  
create table classm as 
select * 
from sashelp.class 
where sex = 'M' or Name = 'Alice';
quit;

proc sql;
insert into class 
select * 
from classm 
where name^="John";
quit;

【讨论】:

    【解决方案2】:

    为什么不使用合并?

    您按作为参考 (id) 的列对两个表进行排序,然后将两个表与所选键合并。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-19
      • 1970-01-01
      • 2018-06-20
      • 1970-01-01
      相关资源
      最近更新 更多