DATA Step, Macro, Functions and more

top 2 maximum and minimum values by proc

Accepted Solution Solved
Reply
Contributor
Posts: 31
Accepted Solution

top 2 maximum and minimum values by proc

Dear All,

 

I have below data.

 

a

1

2

3

4

6

99

118

190

0

4

5

8

 

I want to find out top 2 maximum and minimum values with proc (not by data step or proc sql).

 

is there any proc in sas which can handle the said scenario ?

 

Regards,

Rajesh


Accepted Solutions
Solution
‎11-28-2016 12:32 PM
Super User
Posts: 19,772

Re: top 2 maximum and minimum values by proc

Proc univariate. 

View solution in original post


All Replies
Solution
‎11-28-2016 12:32 PM
Super User
Posts: 19,772

Re: top 2 maximum and minimum values by proc

Proc univariate. 

PROC Star
Posts: 735

Re: top 2 maximum and minimum values by proc

Proc IML ok? Smiley Happy

 

data a;
input a;
infile datalines dlm = ' ';
datalines;
1 
2 
3 
4 
6 
99 
118 
190 
0 
4 
5 
8
;

proc iml;
use a;
   read all var _NUM_ into a;
close a;

call sort(a);
rows = nrow(a);


print (a[1:2, ]), (a[rows - 1:rows, ]);
quit;
☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 239 views
  • 0 likes
  • 3 in conversation