/* ---------------------------------------- | Code 1_3.sas Trends, seasonal dummies, | | and step function inputs. | -----------------------------------------*/ title " ";footnote " "; goptions reset=all; *(1) Print near dropoff ; proc print data = fets.dotairts; var passengers date; where '01jun2001'd < date < '01nov2001'd; run; * (2) Create seasonal dummies, step and point interventions; data airnew; array m_dummy(12); set fets.dotairts; t+1; m=month(date); * /* ; passengers = log(passengers); footnote j=l "Log Transformed"; * */; diff12 = passengers-lag12(passengers); * Span 12 difference ; point = (date = '01sep2001'd); shift = (date > '01aug2001'd); label shift = "9/11/01 shift"; do i=1 to 12; m_dummy(i) = (m=i); * Logical varible ; end; run; proc print data=airnew; where year(date)=2001; var m_dummy1-m_dummy12 date point shift; run; * (3) Fit a model with trend, seasonal dummies, and interventions ; proc reg data=airnew; model passengers = t m_dummy1-m_dummy11 shift point/dw; *Try with 12; output out=out1 residual = R_reg predicted=P; run; * (4) Plot predictions: Regression vs. seasonal differences ; proc gplot data=out1; title h=1.5 "FETS airline data"; plot (passengers P)*date/ overlay legend href='11sep2001'd chref=cyan hminor=1; plot (diff12 R_reg)*date/ overlay legend vref=0 cvref=blue href="11sep2001"d chref=blue hminor=1; symbol1 v=none i=join; * GPLOT will go through device color list"; run; quit;