Guys, I am unsure how to proceed at this point. So I have thousands of rows of data with a hundred different fields. The field values are all integer values. I would like to identify which field contains the highest value in each row.
I can use the LARGEST() function to identify the 3 highest values in each row, but what I really need is the names of those 3 fields (added as 3 extra fields). Any suggestions?
What happens if you have multiples? Which variable would you take? or would you take 3 of the same?
Use an array of sorts with the whichn and vname function.
data have;
set sashelp.pricedata;
array pr{*} price1--price17;
firstvar=vname(pr[whichn(largest(1, of pr{*}), of pr{*})]);
run;
What happens if you have multiples? Which variable would you take? or would you take 3 of the same?
Use an array of sorts with the whichn and vname function.
data have;
set sashelp.pricedata;
array pr{*} price1--price17;
firstvar=vname(pr[whichn(largest(1, of pr{*}), of pr{*})]);
run;
Thanks Reeza -- VNAME was what I was looking for. So I have the above working, the issue now is that some of the rows have all zero values in the fields, and the output in these cases is the first fieldname repeated all 3 times. I would like simply not to display any fieldname if values are 0. But how to do this with the above code?
Then using array will give you more control.
Since not seeing your data ,it is hard to code exactly.
Ksharp
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.