Hi team
I am working on detection of outliers from the payroll data set where I have to detect the outliers on weekly basis. Kindly help me out in writing algorithm in SAS to automate the same.
For reference below is one of the example of the data in which I have to find outliers.
Calls 425 555 235 452 654 785 452 555 665 245 324 245 365 452 754 854 546 456 652 345 246 356 124 758 111 954 845
Thank you
Just to get things started, you can do something like this
data have;
input Calls @@;
datalines;
425 555 235 452 654 785 452 555 665
245 324 245 365 452 754 854 546 456
652 345 246 356 124 758 111 954 845
;
proc univariate data=have;
var Calls;
output out=stats qrange=iqr mean=mean;
run;
data Outliers;
if _n_=1 then set stats;
set have;
if calls lt mean-1.5*iqr | calls gt mean+1.5*iqr;
run;
Hi. There are several ways to do outlier detection in SAS. Do a Google search and you will find tons of examples.. However, it all depends on what you consider and outlier?
How do you define outliers ? out of range [mean-3*std , mean+3*std ] or [mean-2*std , mean+2*std ] ......?
@Ksharp wrote:
How do you define outliers ? out of range [mean-3*std , mean+3*std ] or [mean-2*std , mean+2*std ] ......?
Amount of change from previous value? Above set value? Below set value?
Above set value OR Below set value .
Outlier is an out of range where If a value is higher and lesser than the 3 times of Interquartile Range (IQR)
Do you mean less than or greater than the mean +- 3*IQR?
Just to get things started, you can do something like this
data have;
input Calls @@;
datalines;
425 555 235 452 654 785 452 555 665
245 324 245 365 452 754 854 546 456
652 345 246 356 124 758 111 954 845
;
proc univariate data=have;
var Calls;
output out=stats qrange=iqr mean=mean;
run;
data Outliers;
if _n_=1 then set stats;
set have;
if calls lt mean-1.5*iqr | calls gt mean+1.5*iqr;
run;
Hi
Thank you for the solution I got it.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.