SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

How to drop the extremum

Accepted Solution Solved
Reply
Highlighted
Contributor
Posts: 29
Accepted Solution

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: 496

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;

View solution in original post


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

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: 22,844

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: 22,844

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.

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

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