Solved
Contributor
Posts: 29

# How to drop the extremum

Let's suppose I have 100 values in my data set. If I want to drop the three highest values, as well as the three lowest values, what code would best accomplish this?

Accepted Solutions
Solution
‎10-25-2017 01:19 AM
SAS Super FREQ
Posts: 497

## Re: How to drop the extremum

``````data x;
do i = 1 to 100;
r = uniform(368);
output;
end;
run;
proc sort data=x; by r; run;
data x2;
set x;
if _n_ gt 3 and _n_ lt 98;
run;``````

All Replies
Solution
‎10-25-2017 01:19 AM
SAS Super FREQ
Posts: 497

## Re: How to drop the extremum

``````data x;
do i = 1 to 100;
r = uniform(368);
output;
end;
run;
proc sort data=x; by r; run;
data x2;
set x;
if _n_ gt 3 and _n_ lt 98;
run;``````
Super User
Posts: 23,296

## Re: How to drop the extremum

How are you planning to deal with duplicates. If you have 5 values of 100 as the highest, do all 5 go? What about the next 3 99s?

The rules are ambiguous.

Contributor
Posts: 29

## Re: How to drop the extremum

First, thank you for your valuable reminder.

Since I want to get rid the influence of extremum on my standard deviation, I think I should consider duplicate numbers as one value. So, in your example, if I have 5 duplicates of 100, they would all be gone. They are considered one value, not five.
Super User
Posts: 23,296

## Re: How to drop the extremum

If that’s the goal look at the TRIMMED and/or WINDSOR option in PROC UNIVARIATE.

☑ This topic is solved.