如何只将新(不重复)行插入现有表 - 在proc sql - sas中?

时间:2012-04-16 14:46:21

标签: insert duplicates sas

是否有人知道如何在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中执行此操作,或者数据步骤没问题。

谢谢

2 个答案:

答案 0 :(得分:2)

这对我有用......

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;

答案 1 :(得分:0)

为什么不使用合并?

您按照引用(id)列对两个表进行排序,并将两个表与所选键合并。

相关问题