BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Xinhui
Obsidian | Level 7

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?

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenKuhfeld
Rhodochrosite | Level 12

 

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

4 REPLIES 4
WarrenKuhfeld
Rhodochrosite | Level 12

 

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;
Reeza
Super User

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. 

Xinhui
Obsidian | Level 7
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.
Reeza
Super User

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

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