For example, I want to get dataset2 from dataset1.
From dataset1, all IDs, whose value1 of any specific phase is over 10 points greater than the value2 of a previous phase within the IDs (pointed as arrow), were selected in dataset2.
I am using SAS EG version and it was impossible for me to make such query.
Thank you very much in advance.
You can do this in SQL. To get the rows matching the condition:
select t.*
from t join
t tnext
on tnext.id = t.id and
tnext.phase = t.phase + 1
where tnext.value1 > t.value2 + 10;
Then you can list the ids using in
or exists
:
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
);
Thank you!! With your help I succeeded in selecting the group which I wanted. I also came to know about where-in and join-on clauses.