Hello SAS experts,
I have a series of variables and would like to choose the variable with the largest value.
Some background:
I have ran a program that classifies the probability of individuals belonging to a specific class(y1-y8). I need to write a code to select the highest probability among these classes. I have attached a sample file with 10,000 examinees and their probability for belonging to each class. How can I select the variable with highest value/probability?
Thank you for any help in advance
Not quite sure from your question what type of maximum value you are looking for?
Here are two possible answers to two possible questions...
find the by row maximum value: the max function. ie. ymax=max(of y1-y8);
find the by column maximum value: one option is proc summary. ie. proc means data=out_2 max; var y1-y8; run;
I read your request slightly differently. Would the following provide what you want?
proc summary data=out_2;
var y1-y8;
output out=need (drop=_:) mean=;
run;
proc transpose data=need out=want;
run;
proc sql;
select *
from want
having col1 eq max(col1)
;
quit;
libname xx v9 'c:\'; data want; set xx.out_2; array _y{*} y1-y8; max=max(of y1-y8); i=whichN(max,of _y{*}); max_var=vname(_y{i}); drop max i; run;
Ksharp
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.