Contributor
Posts: 63

# How to do capping and flooring of outlier values?

How to do capping and flooring of outlier values in proc univariate?

Regular Contributor
Posts: 195

## Re: How to do capping and flooring of outlier values?

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...

Contributor
Posts: 63

## Re: How to do capping and flooring of outlier values?

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.

Regular Contributor
Posts: 195

## Re: How to do capping and flooring of 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

Contributor
Posts: 63

## Re: How to do capping and flooring of outlier values?

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;

Valued Guide
Posts: 2,191

## Re: How to do capping and flooring of outlier values?

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 ;

Discussion stats
• 5 replies
• 5371 views
• 2 likes
• 3 in conversation