在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;
谢谢。
答案 0 :(得分:1)
所以你可能已经发现,删除效率不高。
如果你有磁盘空间,我建议你只根据内连接(你想要的记录)创建一个新表,drop 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;