BookmarkSubscribeRSS Feed
R_A_G_
Calcite | Level 5

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

3 REPLIES 3
FriedEgg
SAS Employee

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;

art297
Opal | Level 21

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;

Ksharp
Super User
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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 6278 views
  • 0 likes
  • 4 in conversation