Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Visual Data Mining and Machine Learning or just with programming

Select row based on max value

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 82
Accepted Solution

Select row based on max value

I have a table like this:

col1 col2    col3      col4

A    B      alpha      0.5

A    B      beta       1.00

col4 is numeric.

Now I want the row corresponding to the max value of col4, so I just want to select the second row. How to do this?


Accepted Solutions
Solution
‎09-23-2014 10:43 AM
Super User
Super User
Posts: 7,977

Re: Select row based on max value

Posted in reply to eagles_dare13

You could do:

proc sort data=have (obs=1);

     by descending col4;

run;

Or:

proc sql;

  create table WANT as

  select  *

  from    SASHELP.CLASS

  having  HEIGHT=max(HEIGHT);

quit;

Or proc means...

View solution in original post


All Replies
Solution
‎09-23-2014 10:43 AM
Super User
Super User
Posts: 7,977

Re: Select row based on max value

Posted in reply to eagles_dare13

You could do:

proc sort data=have (obs=1);

     by descending col4;

run;

Or:

proc sql;

  create table WANT as

  select  *

  from    SASHELP.CLASS

  having  HEIGHT=max(HEIGHT);

quit;

Or proc means...

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 9302 views
  • 2 likes
  • 2 in conversation