/* Example Code */ data dowj; format day date7.; informat day date7.; input day $ dj @@; label dj='DJIA Closing Price for Day'; /* Exponential Smoothing Weight */ w=.75; retain ewma1 ewma2 ewma3; /* Starting Value in Series */ if _n_ = 1 then ewma1=dj; /* Single Exponential Smoothing */ else ewma1=w*dj+(1-w)*ewma1; /* Double Exponential Smoothing */ if _n_ le 2 then ewma2=ewma1; else ewma2=w*ewma1+(1-w)*ewma2; /* Triple Exponential Smoothing */ if _n_ le 3 then ewma3=ewma2; else ewma3=w*ewma2+(1-w)*ewma3; cards; 03JAN94 3756.60 04JAN94 3783.90 05JAN94 3798.82 06JAN94 3803.88 07JAN94 3820.77 10JAN94 3865.51 11JAN94 3850.31 12JAN94 3848.63 13JAN94 3842.43 14JAN94 3867.20 17JAN94 3870.29 18JAN94 3870.29 19JAN94 3884.37 20JAN94 3891.96 21JAN94 3914.48 ; proc print data=dowj; var day dj ewma1 ewma2 ewma3; title 'Dow Jones Index Closing Price'; title2 'Exponentially Weighted Moving Averages'; run;