@Xinhui , I think you'll need to get the dates into an actual date format. I suspect your date in t2 is a character of the form "2018/10/01".
data t2_new;
/* set t2; */
/* date_new = input(compress(date,"/"),yymmdd8.); */
date_new = input(compress("2018/10/01","/"),yymmdd8.);
var_from_t2="Hi from T2!";
format date_new yymmddn8.;
run;
data sp2_new;
/* set sp2; */
/* date_new = input("20181001",yymmdd8.); */
date_new = input("20181001",yymmdd8.);
var_from_sp2="Hi from SP2!";
format date_new yymmddn8.;
run;
proc sort data=t2_new; by date_new; run;
proc sort data=sp2_new; by date_new; run;
data want;
merge t2_new(in=a) sp2_new(in=b);
by date_new;
if a;
run;
proc print data=want;
run;
As @PaigeMiller mentioned, if both variables are SAS dates, it won't matter that they differ in display format.
-unison
... View more