SAS Programming

DATA Step, Macro, Functions and more
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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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