BookmarkSubscribeRSS Feed
danielhu
Calcite | Level 5

Hi, can I get some help on how to winsorize my data. I have total of 8 variables (for example, A-H) with 8000 observations that I have to winsorize. Thanks in advance!

3 REPLIES 3
andreas_lds
Jade | Level 19

Maybe that old thread has the answer for you: or this one

JonasE
Calcite | Level 5

Maybe this link will help:

Otherwise look at this solution and you might be able to work from there. It is not the neatest but your question is not so specific. I have used fifth and ninetyfifth percentiles and set those values to missing.

data test;

set sashelp.cars;

keep Horsepower ;

run;

proc univariate data=test noprint;

var Horsepower;

output out=percentiles p5=Horsepower_p5 p95=Horsepower_p95 ;

run;

data want;

if _n_=1 then set percentiles;

set test;

if not (Horsepower_p5 < horsepower < Horsepower_p95) then horsepower=. ;

run;

Ksharp
Super User

IML code:

Code: Program

data have;
call streaminit(1234);
do i=1 to 100;
  a=ceil(rand('uniform')*100);
  b=ceil(rand('uniform')*100);
  output;
end;
drop i;
run;

%let low=0.05;
%let high=0.95;

proc iml;
use have;
read all var _num_ into x[c=vname];
close have;

call qntl(q,x,{&low , &high});
do i=1 to ncol(x);
x[loc(x[,i]<q[1,i]),i]=.;
x[loc(x[,i]>q[2,i]),i]=.;
end;

create want from x[c=vname];
append from x;
close want;
quit;

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 Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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