%do i=1 %to &nbigfirm;
data a; set &big.; if _n_=&n; obs=_n_+1; source='yes';
call symput("n",obs);
run;
proc sort data=&small. out=b (rename=(firm_id=matching_firm assets=assets2)); by industry; run;
data c; merge a b;by industry; matching_diff =abs(assets-assets2); if source='yes'; run;
proc sort; by firm_id matching_diff ; run;
data match; set c; by firm_id matching_diff; if first.firm_id; run; proc print; run;
data result; set result match; if firm_id=. then delete; run; proc print; run;