/* This program generates several different data sets to demonstrate the choice of smoothing models and the use of SAS PROC FORECAST. */ /* Here we generate an ARIMA(0,1,1) model without drift. This data would be appropriate for the simple exponential model that assumes no trend and no seasonality. */ data mc1; y1 = 0.0; a1 = 0; do t = 0 to 250; a = rannor(1444009); y = y1 + a + 0.7*a1; if t > 0 then output; a1 = a; y1 = y; end; proc gplot data=mc1; symbol v=dot c=black i=join h=.8; title1 'Monte Carlo IMA(1) data with no drift and theta(1) = -0.7'; title2 'X=Time Y=IMA(1) Series'; axis1 order=(0 to 250 by 50) label=(f=duplex 'Obs'); axis2 order=(-20 to 50 by 5) label=(f=duplex 'IMA(1) Series'); plot y*t / haxis=axis1 vaxis=axis2; run; /* Here we forecast the IMA(1) series without drift using PROC FORECAST, Method = EXPO, Trend = 1, and Lead = 12. */ title 'Simple Exponential Smoothing'; proc forecast data = mc1 method = expo trend=1 lead = 12 outlimit out=forecast; var y; proc print data = forecast; run; /* Here we generate an ARIMA(0,1,1) model with drift. This data would be appropriate for the Linear (Holt) exponential model that assumes trend but no seasonality. */ data mc2; y1 = 0.9; a1 = 0; do t = 0 to 250; a = rannor(14398); y = y1 + a + 0.7 * a1 + 0.2; if t > 0 then output; a1 = a; y1 = y; end; /* Here we forecast the IMA(1) series with drift using PROC FORECAST, Method = EXPO, Trend = 2, and Lead = 12. */ proc gplot data=mc2; symbol v=dot c=black i=join h=.8; title1 'Monte Carlo IMA(1) data with drift and theta(1) = -0.7'; title2 'X=Time Y=IMA(1) Series'; axis1 order=(0 to 250 by 50) label=(f=duplex 'Obs'); axis2 order=(-5 to 100 by 5) label=(f=duplex 'IMA(1) Series'); plot y*t / haxis=axis1 vaxis=axis2; run; title 'Linear (Holt) Exponential Smoothing'; proc forecast data = mc2 method = expo trend=2 lead = 12 outlimit out=forecast; var y; proc print data = forecast; run; /* This is monthly influenza data taken from Robert H. Shumway, APPLIED STATISTICAL TIME SERIES ANALYSIS, 1988, p. 194. The table is labeled "Country X Monthly Cases of Influenza for 10 Years (1965 - 1974)." */ data influ; format date monyy5.; input date:monyy5. flu @@; cards; jan65 633 feb65 488 mar65 852 apr65 1097 may65 2447 jun65 8111 jul65 16483 aug65 25156 sep65 11980 oct65 7294 nov65 1284 dec65 4674 jan66 3084 feb66 878 mar66 1267 apr66 2530 may66 3175 jun66 3709 jul66 5180 aug66 14263 sep66 10244 oct66 13688 nov66 10277 dec66 6370 jan67 1718 feb67 1474 mar67 2277 apr67 4535 may67 7467 jun67 10791 jul67 7217 aug67 21100 sep67 14033 oct67 21953 nov67 9706 dec67 2782 jan68 2818 feb68 1150 mar68 2276 apr68 4388 may68 27559 jun68 50000 jul68 27650 aug68 31580 sep68 13729 oct68 11441 nov68 3410 dec68 1336 jan69 988 feb69 1055 mar69 2467 apr69 4867 may69 8718 jun69 38448 jul69 35590 aug69 32118 sep69 18391 oct69 11253 nov69 4912 dec69 2190 jan70 1287 feb70 1106 mar70 2092 apr70 5019 may70 7269 jun70 11145 jul70 25515 aug70 25434 sep70 24076 oct70 9605 nov70 5566 dec70 3765 jan71 1697 feb71 1666 mar71 4097 apr71 5808 may71 8963 jun71 17291 jul71 15885 aug71 14330 sep71 14522 oct71 8184 nov71 5956 dec71 4454 jan72 2005 feb72 1990 mar72 3021 apr72 4950 may72 8227 jun72 8251 jul72 15161 aug72 20986 sep72 11168 oct72 5794 nov72 4310 dec72 4102 jan73 2377 feb73 2240 mar73 4245 apr73 6452 may73 15736 jun73 25880 jul73 21354 aug73 26784 sep73 12722 oct73 12353 nov73 7182 dec73 11419 jan74 2563 feb74 2691 mar74 3853 apr74 6326 may74 9362 jun74 10685 jul74 13148 aug74 39093 sep74 19720 oct74 16492 nov74 7035 dec74 12224 ; /* Here we forecast this series using PROC FORECAST, Method=ADDWINTERS, Seasons = Month, Trend = 1, and Lead = 12. */ title 'Forecasting Flu Data using Seasonal Exponential Smoothing'; proc forecast data = influ method = addwinters seasons = month trend=1 lead=12 outlimit out=forecast; var flu; id date; run; proc print data = forecast; run; title 'Influenza in Country X by Month Jan. 1965 - Dec. 1974'; axis1 label=('Year'); axis2 order=(0 to 60000 by 5000) label=(angle=90 'Cases of Influenza'); proc gplot data=influ; plot flu*date / haxis=axis1 vaxis=axis2; symbol1 i=join; format date year4.; run; /* This is the Plano Sales Tax Revenue data provided by Reginald Gray. */ data Plano; input date:monyy5. rev; format date monyy5.; title 'Plano Sales Tax Revenue Data'; title2 'By Month'; datalines; Feb90 2068592 Mar90 867387 Apr90 791878 May90 1731316 Jun90 911839 Jul90 909258 Aug90 1826999 Sep90 964868 Oct90 1020941 Nov90 1881435 Dec90 1075607 Jan91 964977 Feb91 2699324 Mar91 884494 Apr91 1035007 May91 1930143 Jun91 1124814 Jul91 1098136 Aug91 1812798 Sep91 1095294 Oct91 1163039 Nov91 1920424 Dec91 1000743 Jan92 1075763 Feb92 2341127 Mar92 1062449 Apr92 1120898 May92 1939866 Jun92 1316907 Jul92 1284888 Aug92 2098891 Sep92 1375423 Oct92 1201251 Nov92 2165295 Dec92 1301110 Jan93 1251165 Feb93 2986796 Mar93 1271028 Apr93 1228055 May93 2349629 Jun93 1385267 Jul93 1537452 Aug93 2576586 Sep93 1642938 Oct93 1577049 Nov93 2765401 Dec93 1940847 Jan94 1640531 Feb94 3271545 Mar94 1383909 Apr94 1495825 May94 2772734 Jun94 1592051 Jul94 1560732 Aug94 2773904 Sep94 1523255 Oct94 2013622 Nov94 2957306 Dec94 1789103 Jan95 1848972 Feb95 3507801 Mar95 1821378 Apr95 1930585 May95 2823010 Jun95 1970356 Jul95 1970534 Aug95 2982305 Sep95 1795240 Oct95 2145180 Nov95 3021075 Dec95 1908781 Jan96 1957956 Feb96 3955970 Mar96 2119970 Apr96 2208176 May96 3063504 Jun96 2190613 Jul96 2197082 Aug96 3085586 Sep96 2642591 Oct96 2550586 Nov96 3230872 Dec96 2482466 Jan97 2315274 Feb97 4388396 Mar97 2335249 Apr97 1956240 May97 3183566 Jun97 2421722 Jul97 1879301 Aug97 3094563 Sep97 2599894 Oct97 2320012 Nov97 3518486 Dec97 2407487 Jan98 2291118 Feb98 4813948 Mar98 2380134 Apr98 2223477 May98 3378416 Jun98 2876314 Jul98 2650942 Aug98 3788448 Sep98 2651506 Oct98 2450710 Nov98 4118992 Dec98 2434040 Jan99 2763878 Feb99 5227962 Mar99 2762093 Apr99 2528931 May99 4040412 Jun99 2883152 Jul99 3100274 Aug99 4149743 Sep99 3061236 Oct99 2805394 Nov99 3962285 Dec99 3197688 Jan00 3149649 Feb00 5401137 Mar00 3393528 Apr00 2852524 May00 4708691 Jun00 3567883 Jul00 3405732 Aug00 4885709 Sep00 4142396 Oct00 3564755 Nov00 4794159 Dec00 3459785 Jan01 3600702 Feb01 5789400 Mar01 3283596 Apr01 3411052 May01 4783941 Jun01 3706871 Jul01 3756080 Aug01 4318154 Sep01 3201376 Oct01 3502712 Nov01 4864603 Dec01 3108517 Jan02 3357796 Feb02 5904823 Mar02 2951480 Apr02 3185525 May02 4729624 Jun02 3282329 Jul02 3271971 Aug02 4559047 Sep02 3350292 Oct02 3286394 Nov02 4566940 Dec02 2863028 Jan03 3049842 Feb03 5780438 Mar03 3286533 Apr03 3016081 May03 4533575 Jun03 3296881 Jul03 3535071 Aug03 5290070 Sep03 3323063 Oct03 3318144 Nov03 5206490 Dec03 3240679 Jan04 3673046 Feb04 6166054 Mar04 3573983 Apr04 2999256 May04 5177550 Jun04 3845943 Jul04 3492933 Aug04 4975878 Sep04 3531498 Oct04 3611446 Nov04 5145814 Dec04 3260597 Jan05 3715755 Feb05 6239931 Mar05 3730730 Apr05 3431157 May05 5404423 Jun05 4049371 Jul05 3648390 Aug05 5394527 Sep05 3968853 Oct05 3970771 Nov05 5384216 ; /* Here we forecast this series using PROC FORECAST, Method=ADDWINTERS, Seasons = Month, Trend = 2, and Lead = 13. */ title1 'Forecasting Plano Sales Tax Revenue Data'; title2 'Using Winters Additive Method with Trend and Seasonal Factors'; proc forecast data = plano method = addwinters seasons = month trend=2 lead=13 outlimit out=forecast; var rev; id date; run; proc print data = forecast; run; goptions cback=white colors=(black) border reset=(axis symbol); axis1 offset=(1 cm) label=('Year') minor=none order=('01jan90'd to '01nov06'd by year); axis2 label=(angle=90 'Plano Sales Tax Revenue') order=(0 to 7000000 by 1000000); symbol1 i=join; proc gplot data=plano; format date year4.; plot rev*date / haxis=axis1 vaxis=axis2 vminor=1; run;