/* This program generates the stationary AR(1) model */ data mc; x1 = 0; iseed = 12345; do t = 0 to 100; a = rannor(iseed); x2 = 0.5*x1 + a; if t > 0 then output; x1 = x2; end; keep t x2; proc gplot data=mc; symbol v=dot c=black i=join h=.8; title1 'Monte Carlo AR(1) data with phi(1) = 0.5'; title2 'X=Time Y=AR(1) Series'; axis1 order=(0 to 100 by 10) label=(f=duplex 'Obs'); axis2 order=(-5 to 5 by 1.0) label=(f=duplex 'AR(1) Series'); plot x2*t / haxis=axis1 vaxis=axis2; title; data mc; set mc; y = x2; time = _N_; proc arima data=mc; identify var = y; estimate p = 1; forecast lead=20 id=time out=pred; run; proc gplot data=pred; title1 'Forecasts Based on AR(1) Model'; title2 'X=Time Y=AR(1) Series'; symbol1 i=none v=star h=0.5; symbol2 i=spline v=circle h=0.5; symbol3 i=spline l=5; plot y * time = 1 forecast * time = 2 ( l95 u95 ) * time = 3 / overlay href = 100.5; run;