新的SAS用户:我有一个由PROC SQL语句创建的数据集(表):
proc sql;
create table work.dm_1 as
select distinct a.subject, c.dsyn as DSYN_DS_1, d.dsyn as DSYN_DS_2
from s_raw.dm_1 a
left join work.edt_eg b
on a.subject=b.subjid
left join s_raw.ds_1 c
on a.subject=c.subject
left join s_raw.ds_2 d
on a.subject=d.subject
where c.DSYN='NO' and d.DSYN='NO';
quit;
使用此表(work.dm_1)的结果,我想修改另一个(现有的)表(work.edt_ecg,从前一个过程创建)来选择匹配的记录(使用dm_1中的主题和edt_eg中的subjid)上面的proc sql中的表,并更新表work.edt_ecg。我尝试过以下方法:
proc sql;
update table work.edt_eg as
select *
from work.edt_eg where subjid in (select distinct subject from work.dm_1);
quit;
但它不适合我!欢迎任何想法
答案 0 :(得分:0)
您应该使用所需数据的子集创建新表或视图
create view work.edt_eg_wanted as
select *
from work.edt_eg
where subjid in (select distinct subject from work.dm_1);
或从现有表中删除所有不需要的观察(1)
delete *
from work.edt_eg
where subjid not in (select distinct subject from work.dm_1);
(由于您未提供样本数据,因此未对此代码进行测试)
(1)观察是SAS用于表中行的单词。这是因为SAS最初由统计学家编写。