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?
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;
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;
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.
If that’s the goal look at the TRIMMED and/or WINDSOR option in PROC UNIVARIATE.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.