I need to find out least 3 values from the list of ten variables.
e.g.
Distance1 | Distance2 | Distance3 | Distance4 | Distance5 | Distance6 | Distance7 | Distance8 | Distance9 | Distance10 |
15.46791785 | 27.07151463 | 28.99654603 | 229.332241 | 237.8000057 | 12.01979627 | 31.54472452 | 22.26341721 | 27.26892156 | 23.14074428 |
19.56490681 | 31.14826968 | 5.781924029 | 215.2916435 | 222.8782588 | 25.21045093 | 8.626908624 | 16.60635164 | 9.818619941 | 17.35681137 |
Desired output:
Distance1 | Distance2 | Distance3 | Distance4 | Distance5 | Distance6 | Distance7 | Distance8 | Distance9 | Distance10 | min-distance1 | min-distance2 | min-distance3 |
15.46791785 | 27.07151463 | 28.99654603 | 229.332241 | 237.8000057 | 12.01979627 | 31.54472452 | 22.26341721 | 27.26892156 | 23.14074428 | 12.01979627 | 15.46791785 | 22.26341721 |
19.56490681 | 31.14826968 | 5.781924029 | 215.2916435 | 222.8782588 | 25.21045093 | 8.626908624 | 16.60635164 | 9.818619941 | 17.35681137 | 5.781924029 | 8.626908624 | 9.818619941 |
With the 'min' function we can find out only the least 1 variable, but I was why wondering to get the least three values.
Appreciate your inputs in advance.
Hello,
data have;
input a b c d e;
datalines;
1 2 3 4 5
10 50 20 30 40
50 60 40 30 30
;
data want;
array mindistance{3};
set have;
do i=1 to 3;
mindistance{i}=smallest(i,a,b,c,d,e);
end;
run;
Hello,
data have;
input a b c d e;
datalines;
1 2 3 4 5
10 50 20 30 40
50 60 40 30 30
;
data want;
array mindistance{3};
set have;
do i=1 to 3;
mindistance{i}=smallest(i,a,b,c,d,e);
end;
run;
Thanks.
how to find the maximum 3 values for the same scenario?
I got it. It can be done via largest function.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.