BookmarkSubscribeRSS Feed
venkatard
Calcite | Level 5

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

5 REPLIES 5
UrvishShah
Fluorite | Level 6

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


venkatard
Calcite | Level 5

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.

UrvishShah
Fluorite | Level 6

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


venkatard
Calcite | Level 5

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;

Peter_C
Rhodochrosite | Level 12

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 ;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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