EDITED: THIS HAS BEEN REVISED FOR GENERAL PURPOSE. SEE THE NEXT POST OF MINE
You want to lookup an array giving its row and column to get its content. It can be done via Hash objects and arrays. Arrays are preferable because it is faster and takes less memory. I am using a temporary 2-dimensional array for not crowding the PDV, Also, I am using macro variables to make the array dynamic.
%let start_row = 40;
%let end_row = 45;
%let start_col = 2;
%let end_col = 6;
data _null_;
/** Load the 2-dimensional Array **/
if _n_ = 1 then do until(eof);
set have end = eof;
array ind[&start_row:&end_row, &start_col:&end_col] _temporary_;
array f f&start_col - f&end_col;
row = age;
do i = &start_col to &end_col;
col = input(compress(vname(f[i-1]),,'kd'),8.);
ind[row,col] = f[i-1];
*put row = col = ind[row, col] =;
end;
end;
/** Lookup the Array **/
do age = 42, 40, 45;
do i = 5, 2, 6, 3;
put ind[age, i] =;
end;
put '==================================';
end;
stop;
run;
... View more