例如,我想从数据集1获取数据集2。
从数据集1中,在数据集2中选择了任何特定阶段的值1比这些ID中的前一个阶段的值2(指向箭头)大10个点以上的所有ID。
我使用的是SAS EG版本,因此无法进行此类查询。
非常感谢。
您可以在SQL中执行此操作。要获取与条件匹配的行:
select t.*
from t join
t tnext
on tnext.id = t.id and
tnext.phase = t.phase + 1
where tnext.value1 > t.value2 + 10;
然后您可以使用in
或exists
列出ID:
select t.*
from t
where t.id in (select t2.id
from t t2 join
t tnext
on tnext.id = t2.id and
tnext.phase = t2.phase + 1
where tnext.value1 > t2.value2 + 10
);
DIF()
)过滤器主表
data temp;
set have;
by id phase;
/*Part 1*/
difference = dif(value1);
if first.id difference = .;
/*Part 2*/
if difference > 10 then output;
run;
/*Part 3*/
proc sql;
create table want as
select * from have
where ID in (select distinct ID from temp);
quit;