【发布时间】: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 中执行此操作,或者数据步骤很好。
谢谢
【问题讨论】:
-
在表定义中添加主键是另一种强制表拒绝重复项的方法。见:support.sas.com/documentation/cdl/en/sqlproc/62086/HTML/default/…
-
我不太明白你的情况。但似乎构建一个复杂的
where子句如where (sex = 'M' or Name = 'Alice') or sex = 'F'可能是解决方案。
标签: insert duplicates sas