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-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
  • 5 replies
  • 11292 views
  • 2 likes
  • 3 in conversation