Hi @VDD Your code works well. But I have a reverse task from the dataset and I tried but it endup up with partial output. Task 1 (COMPLETED) First choose the MAX(date_B) and find the MIN(date_A) > MAX(date_B) and WHERE grade = '.' TASK 2 (PARTIAL OP) ----- choose the MIN(date_B) and find the MAX(date_A) < MIN(date_B) and WHERE grade = '.' The example dataset which I mention in earlier post performs well with TASK2. But not works in my original dataset. /***** TASK 1 **********/ /* You suggested*/ /** COMPLETED**/
Proc Sql;
create table Mater_min as
select distinct a.P_IDA,
max(a.Record_Date_A),a.Record_Date_A,a.Grade_A
from Master as a, SubMaster as b
where a.Grade_A = '' and a.P_IDA = b.P_IDB and a.Record_Date_A > b.Record_date_B
group by a.P_IDA,b.P_IDB
having a.Record_Date_A = min(a.Record_Date_A) and b.Record_Date_B = max(b.Record_date_B);
quit;
/******* TASK 2****/ /*What I edited for reverse method*/ /*Results PArtial Output*******/
Proc Sql;
create table Mater_max as
select distinct a.P_IDA,
min(a.Record_Date_A),a.Record_Date_A,a.Grade_A
from Master as a, SubMaster as b
where a.Grade_A = '' and a.P_IDA = b.P_IDB and a.Record_Date_A < b.Record_Date_B
group by a.P_IDA,b.P_IDB
having a.Record_Date_A = max(a.Record_Date_A) and b.Record_Date_B = min(b.Record_date_B);
quit; HERE I ATTACH the original dataset Please gothrough it and let me know my error. Thanks in Advance!
... View more