Considering the table below, how can I find out the position (1st, 2nd element…) of the highest NPV for each Stand? (for Stand 6 it would return 3rd, for Stand 7 it would return 2nd). I tried the ord() function but it works only with one-dimensional sets, which is not the case since I am trying to return the value of a parameter.

I wonder if you really want to have the position - i.e. k’th age value in the stand is the highest NPV. It seems it would be more useful to have a set of tuples that indicate where the best NPV is to be found: in a GAMS model, this would be more useful than the position.

Something like this untested code should work for computing both:

parameters
npv(stand,age)
position(stand)
mx(stand)
p
;
set bestNPV(stand,age);
* read values into npv
position(stand) = NA;
mx(stand) = -INF;
bestNPV(stand,age) = no;
loop{stand,
p = 1;
loop{age,
if {(npv(stand,age) > mx(stand),
position(stand) = p;
mx(stand) = npv(stand,age);
bestNPV(stand,a2) = no;
bestNPV(stand,age) = yes;
};
p = p + 1;
};
};

Thanks for your reply.
Well, my initial idea was to find the position of the highest NPV and use this number to search for another parameter value correspondent to the same position, but in another table. However, the code you provided gave me an insight into another way of doing so, which is more straightforward. So yes, it worked to solve my problem. Thanks