The SAS functions of inputn,inputc, putn,putc are allowed a format name argument as a variable. But it has limitations about how many formats can be loaded at running time.
data fmt;
do i=1 to 5000;
fmtname=catt('_',i,'_');
start=i;
label=i;
type='I';
output;
end;
run;
options nonotes;
proc format cntlin=fmt;
run;
options notes;
data test;
*do i=1 to 50;
do i=1 to 5000;
fmtname=catt('_',i,'_');
value=inputn(compress(put(i,best.)),fmtname);
output;
end;
run;
proc print;run;