You would make your life sooooo much easier if you used actual SAS dates instead of a variable with values like 201701.
You also don't need to format the values before you use them in PROC SQL. Use formats only when a human has to view the results in an understandable form; PROC SQL doesn't care, it can use the actual date values, so there's no point in formatting them to be actual readable dates.
data _null_;
begin_date=mdy(1,1,2017);
end_date=intnx('month',begin_date,12,'s')-1;
/* If you want more than a 12 month interval, replace 12 with the number of months you want */
call symputx('begin_date',begin_date);
call symputx('end_date',end_date);
run;
proc sql;
...
where t2.date between &begin_date and &end_date;
quit;
Side note: I can't test this right now, but I do not remember if the BETWEEN operator will select the observation if the t2.date value is exactly equal to &begin_date or exactly equal to &end_date. In other words, I don't remember if BETWEEN uses greater than and less than; or greater than or equal to and less than or equal to. But you can test this and modify the code accordingly.
... View more