Automatic Outlier Detection
/*--------------------------------------------------------------
SAS Sample Library
Name: x12ex05.sas
Description: Example program from SAS/ETS User's Guide,
The X12 Procedure
Title: Automatic Outlier Detection
Product: SAS/ETS Software
Keys: seasonal adjustment of time series
PROC: X12
Notes:
--------------------------------------------------------------*/
data sales;
set sashelp.air;
sales = air;
date = intnx( 'month', '01sep78'd, _n_-1 );
format date monyy.;
run;
title 'Automatic Outlier Identification';
proc x12 data=sales date=date;
var sales;
transform function=log;
arima model=( (0,1,1)(0,1,1) );
outlier;
estimate;
x11;
output out=nooutlier a1 b1 d10;
run ;
proc x12 data=sales date=date;
var sales;
transform function=log;
arima model=((0,1,1) (0,1,1));
outlier cv=3.3;
estimate;
x11;
output out=outlier(obs=50) a1 a8 a8ao a8ls b1 d10;
run;
proc print data=outlier(obs=50);
run;
proc sgplot data=outlier;
series x=date y=sales_A1 / name='A1' markers
markerattrs=(color=red symbol='circle')
lineattrs=(color=red);
series x=date y=sales_B1 / name='B1' markers
markerattrs=(color=black symbol='asterisk')
lineattrs=(color=black);
yaxis label='Original and Outlier Adjusted Time Series';
run;
data both;
merge nooutlier(rename=(sales_D10=unadj_D10)) outlier;
run;
title 'Results of Outlier Identification on Final Seasonal Factors';
proc sgplot data=both;
series x=date y=unadj_D10 / name='unadjusted' markers
markerattrs=(color=red symbol='circle')
lineattrs=(color=red)
legendlabel='Unadjusted for Outliers';
series x=date y=sales_D10 / name='adjusted' markers
markerattrs=(color=blue symbol='asterisk')
lineattrs=(color=blue)
legendlabel='Adjusted for Outliers';
yaxis label='Final Seasonal Factors';
run;