Resources

Outlier Detection and Removal

/*--------------------------------------------------------------

                    SAS Sample Library

        Name: x11ex03.sas
 Description: Example program from SAS/ETS User's Guide,
              The X11 Procedure
       Title: Outlier Detection and Removal
     Product: SAS/ETS Software
        Keys: seasonal adjustment of time series
        PROC: X11
       Notes:

--------------------------------------------------------------*/

data a;
   retain seed 99831;
   do kk = 1 to 48;
      x = kk + 100 + rannor( seed );
      date = intnx( 'month', '01jan1970'd, kk-1 );
      if kk = 20 then x = 2 * x;
      else if kk = 30 then x = x / 10;
      output;
      end;
run;

proc x11 data=a;
   monthly date=date additive
           fullweight=3.0 zeroweight=3.5;
   var x;
   table d9;
   output out=b b1=original e1=e1;
run;

proc sgplot data=b;
   series x=date y=original / markers
                            markerattrs=(color=red symbol='asterisk')
                            lineattrs=(color=red)
                            legendlabel="unmodified" ;
   series x=date y=e1       / markers
                            markerattrs=(color=blue symbol='circle')
                            lineattrs=(color=blue)
                            legendlabel="modified" ;
   yaxis label='Original and Outlier Adjusted Time Series';
run;