How to do capping and flooring of outlier values in proc univariate?
Hi,
To set the limit of outliers to be printed, you can use the NEXTRAOBS = n option in proc univariate statement...By default, proc univariate give you maximum and minimum five values from the dataset...you can set the limit by using NEXTRAOBS = n option...
I have a dataset which has many variables- By using proc univariate i found the outliers. Now i want to cap and floor the outlier values.
Try the following code...
ODS OUTPUT extremeobs = extremeobs;
proc univariate data = dsn noprint;
var ...;
run;
ODS OUTPUT CLOSE;
proc sql;
select min(low) as min_extreme,
max(high) as high_extreme
from extremeobs;
quit;
Hope it meets the requirement...
Thanks,
Urvish
I have used the below code and got the result. Thanks
ODS OUTPUT extremeobs = extremeobs;
proc univariate data = lcs_beta.studentgpadevelopment plot ;
var no_of_posts_New;
output out=inc pctlpre=Q_ pctlpts=5, 95 ;
run;
ODS OUTPUT CLOSE;
thank you for clarifying what you wanted.
I had thought you wanted to apply 5 and 95% filters, not just "collect" the P5 and P95 stats
an alternate (and I think simpler because it doesn't use ods)
proc means data= your.data min p5 p95 max ;
var no_of_posts_New;
output out= top_tail_pt p5= lower p95=upper ;
run ;
*****
and if you want to apply these stats ;
**** first put the 5pt-pctiles into macro vars;
proc sql noprint ;
select lower, upper into :low, :upp from top_tail_pt(obs=1) ;
quit ;
****** and now use them ;
data top_and_tailed ;
set your.data ;
where not (no_of_posts_New between &low and &upp) ;
run ;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.