For this scenario , you could match this condition by operator BETWEEN AND.
proc sql;
create table CLIN_AE (SUBJID char(11), AEDECOD char(100), AESTDAT num format=date9.);
insert into clin_ae (subjid, aedecod, aestdat)
values ('101-001-001','Rash','30MAY2025'd)
values ('101-001-001','Rash','18JUN2025'd);
create table SAFE_AE (USUBJID char(11), DECOD char(100), STDTC num format=date9.);
insert into safe_ae (usubjid, decod, stdtc)
values ('101-001-001','Rash','30MAY2025'd)
values ('101-001-001','Rash','19JUN2025'd);
create table compare as
select a.*, b.*
from clin_ae as a full join safe_ae as b
on a.subjid=b.usubjid & a.aedecod=b.decod & b.stdtc between a.aestdat and a.aestdat+1;
quit;
data compare;
set compare;
if aestdat^=stdtc then DISCREP='Start Dates not Matching';
run;
... View more