@stevo642
The ranks given to second row seems to be wrong. I think it has to be 3 1 2. I have less expertise in IML. Do you accept a Data Step solution?
The steps include the sorting of each row by using SORTN() function and at the same time switching the index of the array. Then re-ordered index will be the rank. SMALLEST() takes care of the sorting in the background and returns
the i-th smallest value. Using WHICHN() with the i-th smallest value gives the desired Rank.
Note, no attempt is made to check for ties.
%let vn = 3;
data rank;
set A;
array x x1-x&vn;
array R R1 - R&vn;
do i = 1 to dim(x);
R[i] = whichN(smallest(i, of x[*]), of x[*]);
put R[i] =;
end;
keep R:;
run;
... View more