Here is one way to do this, using a SQL view to generate the regression windows:
/* Window size in years */
%let window=2;
proc sql;
create view temp as
select
a.industry,
a.product,
a.date as refDate,
b.date,
b.x, b.y
from
have as a inner join
have as b on a.industry=b.industry and a.product=b.product and
b.date between intnx("year", a.date, -&window., "same") and a.date
group by a.industry, a.product, a.date
having count(distinct b.date) >= 2*&window.
order by industry, product, refDate, date;
quit;
/* For testing only: */
proc sql outobs=50;
select * from temp;
quit;
proc reg data=temp outest=want noprint;
by industry product refDate;
model y = x;
run;
proc print data=want(obs=5) noobs;
var industry product refDate Intercept x; run;
... View more