/* Monthly Sales (in quantity units) of widgets at Fomby Inc from Jan 1998 to Aug 2014 */ data sales; input sales @@; date = intnx( 'month', '31dec96'd, _n_ ); format date monyy.; datalines; 144549 137310 140151 132112 138168 145583 157878 162901 147584 144062 144366 154966 159913 143257 147846 139292 147088 160945 173467 177109 156385 153951 147881 153305 157254 142472 150043 142021 153513 156161 177992 173871 152222 151978 149841 159736 164325 147080 155481 146217 153231 162442 176816 179714 155223 154944 152794 169372 178329 156684 164174 153167 157370 173392 186434 186403 165035 163746 169085 183877 196372 162734 169157 156853 169332 180787 198930 196126 176265 166402 167099 184267 197835 173504 173193 159738 175236 188312 202682 206418 185572 175802 176172 191865 209692 186337 182849 169962 178069 186682 202255 204850 180751 179716 177506 188703 200005 188715 187464 168720 175734 189430 216776 215393 191485 178555 178550 195613 206467 179613 185553 172545 177806 202702 220373 210403 186838 181352 175570 195590 209403 180299 187687 172580 177147 186128 210584 205656 180662 172966 173377 184722 195579 172479 182488 170372 174392 191048 220165 229957 195604 182931 182949 212319 216632 189564 200107 181084 192217 209649 221245 229296 195198 190936 190380 199996 227856 198242 194970 184877 196790 205363 226722 226050 202499 194789 192427 219255 217470 192336 196834 186074 197315 215015 242672 225166 206692 197754 196432 213551 222749 194034 201849 189496 206074 225589 247915 247645 213008 203009 200258 220500 237600 216702 213838 195809 208180 232507 257235 267408 220023 210377 209394 232550 231343 219066 226436 207749 219803 235397 256744 258335 ; title 'Fomby Inc Monthly Sales of Widgets in quantity units'; symbol1 i=join v=star; proc gplot data=sales; plot sales * date = 1 / haxis= '1jan97'd to '1jan15'd by year; run; /* A presentation of the 12 step ahead forecasts produced by Additive Winters method. */ Title 'Additive Winters Seasonal Model Results'; proc esm data=sales out = result1 lead=12 print = all plot=forecastsonly; id date interval=month; forecast sales / model=addseasonal; run; /* Producing the sum of the first through two step-ahead forecasts and its standard error. Use this in the calculation of the REORDER POINT FOR OPTIMAL INVENTORY CONTROL */ proc esm data=sales out = result3 lead = 2 startsum = 1 print = all plot=forecastsonly; id date interval=month; forecast sales / model=addwinters; run; /* In addition to trend, there is seasonal variation in the data. This is indicated by the below Buys-Ballot plot and the nature of the autocorrelations of the differenced data at lags 12 and 24 */ /* Buys-Ballot Plot of Season by Year */ data sales; set sales; series_yr = year(date); series_month = month(date); label series_yr = "Series Year"; run; /*Creates the Seasons by Year Buys-Ballot seasonality graph*/ /*Set Options*/ goptions cback=white colors=(black) border reset=(axis symbol); /*Sets the axis parameters*/ axis1 label=('Month') minor=none value=('Jan' 'Feb' 'Mar' 'Apr' 'May' 'Jun' 'Jul' 'Aug' 'Sep' 'Oct' 'Nov' 'Dec') order=(1 to 12 by 1) offset = (2) width = 3; axis2 label=(angle=90 'Fomby Inc Monthly Sales Data') order=(120000 to 280000 by 10000); /*Creates a Unique symbol and line for each of the 18 years*/ symbol1 color=black interpol=spline value=none; symbol2 color=blue interpol=spline value=none; symbol3 color=brown interpol=spline value=none; symbol4 color=libg interpol=spline value=none; symbol5 color=cyan interpol=spline value=none; symbol6 color=gold interpol=spline value=none; symbol7 color=gray interpol=spline value=none; symbol8 color=green interpol=spline value=none; symbol9 color=lilac interpol=spline value=none; symbol10 color=steel interpol=spline value=none; symbol11 color=magenta interpol=spline value=none; symbol12 color=maroon interpol=spline value=none; symbol13 color=olive interpol=spline value=none; symbol14 color=tan interpol=spline value=none; symbol15 color=salmon interpol=spline value=none; symbol16 color=violet interpol=spline value=none; symbol17 color=orange interpol=spline value=none; symbol18 color=red interpol=spline value=none; /* Graph the data - Seasons by Year */ title 'Fomby Inc Monthly Sales of Widgets'; title2 'Buys-Ballot "Seasons By Year" Plot'; legend1 position = (bottom center outside); proc gplot data=sales; plot sales*series_month=series_yr / haxis=axis1 vaxis=axis2 vminor=1 legend=legend1; run; /* Also there seems to be seasonality in the data because the differenced data is highly correlated at lags 12 and 24. See below. */ Title 'Autocorrelation Function of the Differenced Data'; proc arima data = sales; identify var = sales(1); run;