options ls=72; /*----------------------------------------------------------- | Data from Shipping Liu. Sales of milk in Hawaii. In April | | of '82 news of milk contamination was released. Sales fell | | and bottomed out in May then returned toward the previous | | level slowly. | |____________________________________________________________*/ data liu; input dddd $ sales; retain date '01jan77'd; date=intnx('month',date,1); label sales = 'Milk Sales'; title 'Effect of Negative Publicity (Contamination)'; title2 'on Milk Sales'; x = (date='01apr82'd); x2 = (date>'01mar82'd); ** check for permanent shift **; format date monyy.; if _n_=1 then do; Plag=0; Xlag=0; end; P = - 3167440*X - 4855974*xlag + .56562*Plag ; YHAT = 8674594 + P -1079129*x2; output; retain; Plag=P ; xlag=x; cards; FEB77 9331400 MAR77 8366100 APR77 9357500 MAY77 8674600 JUN77 9106200 JUL77 7522500 AUG77 7797800 SEP77 7980700 OCT77 9436400 NOV77 9170500 DEC77 9060600 JAN78 8414700 FEB78 9207000 MAR78 8124600 APR78 9216900 MAY78 9310700 JUN78 9406200 JUL78 8004100 AUG78 8062200 SEP78 8322100 OCT78 9353400 NOV78 9432600 DEC78 9060100 JAN79 9041600 FEB79 9385200 MAR79 8666200 APR79 9721700 MAY79 9416400 JUN79 9523700 JUL79 8601100 AUG79 8442400 SEP79 8583800 OCT79 8883600 NOV79 9076300 DEC79 8267200 JAN80 9248300 FEB80 9470800 MAR80 9289600 APR80 9563500 MAY80 9462900 JUN80 9603800 JUL80 8216000 AUG80 8413300 SEP80 8525200 OCT80 9012400 NOV80 9297300 DEC80 8717500 JAN81 8524000 FEB81 9212700 MAR81 8415200 APR81 8565100 MAY81 9164100 JUN81 9293100 JUL81 7892100 AUG81 8345700 SEP81 8249400 OCT81 8884000 NOV81 8938400 DEC81 8186200 JAN82 8265100 FEB82 8483400 MAR82 7768100 APR82 4443700 MAY82 1460800 JUN82 4119000 JUL82 5342600 AUG82 5913000 SEP82 6098000 OCT82 6587700 NOV82 7344500 DEC82 7081900 JAN83 7199700 FEB83 7642900 MAR83 6960400 APR83 8446100 MAY83 8075100 JUN83 8367600 JUL83 6906300 ; * Plot the data ; proc print; proc gplot; plot YHAT*date sales*date / overlay href = '01apr82'd; symbol1 v=none i=join c=red w=2; symbol2 v=dot c=blue h=1.5; * Check ARIMA structure using pre-intervention data; proc arima; identify var=sales; where date < '01apr82'd; e p=(1,2)(12) ml; e p=(1)(12) q=(2) ml; * Fit intervention model. MA term allows 2 successive dropoffs before recovery ; proc arima; identify var=sales noprint crosscor=(x x2); e input=( (1) /(1) x x2) p=(1)(12) q=(2) ml; run;