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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.