Sas 在联接时删除表

Sas 在联接时删除表,sas,proc-sql,Sas,Proc Sql,在T-SQL中,我曾经能够执行以下操作: delete t1 from table1 t1 join table2 t2 on t1.rowid = t2.rowid and t1.value <> t2.value 我希望在SAS也能做到这一点 获取上面的代码并在proc-sql中包装;退出;抛出语法错误 这是我唯一的选择吗 proc sql; delete from table1 t1 where t1.value <> (select t2.value from

在T-SQL中,我曾经能够执行以下操作:

delete t1
from table1 t1
join table2 t2 on t1.rowid = t2.rowid and t1.value <> t2.value
我希望在SAS也能做到这一点

获取上面的代码并在proc-sql中包装;退出;抛出语法错误

这是我唯一的选择吗

proc sql;
delete from table1 t1
where t1.value <> (select t2.value from table2 t2 where t1.rowid = t2.rowid) 
and t1.rowid in (select t2.rowid from table t2);
quit;

谢谢。

所以你可能已经明白,删除不是很有效

如果您有足够的磁盘空间,我建议您只需基于内部数据创建一个新表,然后连接所需的记录,删除table1,并重命名结果table1

%let n=1000000;

data table1;
do rowid=1 to &n;
    value = rowid**2;
    output;
end;
run;

data table2;
do rowid=1 to &n;
    value = (mod(rowid,2)=1)*rowid**2;
    output;
end;
run;

proc sql noprint;
create table table1_new as
select a.*
    from table1 as a
      inner join
         table2 as b
      on a.rowid=b.rowid
       and 
         a.value = b.value;

drop table table1;

quit;

proc datasets lib=work nolist;
change table1_new = table1;
run;
quit;

如果您需要在适当的位置进行编辑,请让我知道并解释原因。“为什么”将有助于确定实现这一目标的最佳途径。