ARIMA Modeling
/*--------------------------------------------------------------
SAS Sample Library
Name: ucmex08.sas
Description: Example program from SAS/ETS User's Guide,
The UCM Procedure
Title: ARIMA Modeling
Product: SAS/ETS Software
Keys: equally spaced univariate time series data
PROC: UCM
Notes:
--------------------------------------------------------------*/
data Data1;
set sashelp.air;
logair = log(air);
run;
data Data2;
set data1;
if year(date) >= 1955 and month(date) < 12 then logair = .;
run;
data Data3;
set data1;
if (year(date) = 1949 and month(date) = 7) then logair = .;
if ( year(date) = 1957 and
(month(date) = 6 or month(date) = 7 or month(date) = 8))
then logair = .;
if (year(date) = 1960 and month(date) = 7) then logair = .;
run;
data Data4;
set data1;
if month(date) = 7 then logair = .;
if year(date) = 1957 and (month(date) = 6 or month(date) = 8)
then logair = .;
run;
proc ucm data=Data1;
id date interval=month;
model logair;
irregular q=1 sq=1 s=12;
deplag lags=(1)(12) phi=1 1 noest;
estimate outest=est1;
forecast outfor=for1;
run;
proc ucm data=Data2;
id date interval=month;
model logair;
irregular q=1 sq=1 s=12;
deplag lags=(1)(12) phi=1 1 noest;
estimate outest=est2;
forecast outfor=for2;
run;
proc ucm data=Data3;
id date interval=month;
model logair;
irregular q=1 sq=1 s=12;
deplag lags=(1)(12) phi=1 1 noest;
estimate outest=est3;
forecast outfor=for3;
run;
proc ucm data=Data4;
id date interval=month;
model logair;
irregular q=1 sq=1 s=12;
deplag lags=(1)(12) phi=1 1 noest;
estimate outest=est4;
forecast outfor=for4;
run;
/*---- Table1 --------------*/
data e1(drop=estimate std);
set est1(keep=parameter estimate std);
est1 = estimate;
std1 = std;
run;
data e2(drop=estimate std);
set est2(keep=parameter estimate std);
est2 = estimate;
std2 = std;
run;
data e3(drop=estimate std);
set est3(keep=parameter estimate std);
est3 = estimate;
std3 = std;
run;
data e4(drop=estimate std);
set est4(keep=parameter estimate std);
est4 = estimate;
std4 = std;
run;
data table1;
merge e1 e2 e3 e4;
if _n_ > 1 and _n_ <= 3; *exclude error var and deplag parameters;
run;
/*---- Table2 --------------*/
data f1(drop=forecast std);
set for1(keep=date forecast std);
where year(date) > 1960;
for1 = forecast;
std1 = std;
run;
data f2(drop=forecast std);
set for2(keep=date forecast std);
where year(date) > 1960;
for2 = forecast;
std2 = std;
run;
data f3(drop=forecast std);
set for3(keep=date forecast std);
where year(date) > 1960;
for3 = forecast;
std3 = std;
run;
data f4(drop=forecast std);
set for4(keep=date forecast std);
where year(date) > 1960;
for4 = forecast;
std4 = std;
run;
data table2;
merge f1 f2 f3 f4;
by date;
run;
/*---- Table3 --------------*/
data table3(drop=S_series VS_SERIES);
set for2(keep=date S_series VS_SERIES);
where year(date) = 1957 and month(date) < 12;
estimate = S_series;
std = sqrt( VS_SERIES );
run;
data table3;
merge data1(keep=date logair) table3;
where year(date) = 1957 and month(date) < 12;
by date;
run;
/*---- Table4 --------------*/
data table4(drop=S_series VS_SERIES);
set for3(keep=date S_series VS_SERIES);
where (year(date) = 1949 and month(date) = 7) or
( year(date) = 1957 and
(month(date) = 6 or month(date) = 7 or month(date) = 8))
or
(year(date) = 1960 and month(date) = 7);
estimate = S_series;
std = sqrt( VS_SERIES );
run;
data table4;
merge data1(keep=date logair) table4;
where (year(date) = 1949 and month(date) = 7) or
( year(date) = 1957 and
(month(date) = 6 or month(date) = 7 or month(date) = 8))
or
(year(date) = 1960 and month(date) = 7);
by date;
run;
/*---- Table5 --------------*/
data table5(drop=S_series VS_SERIES);
set for4(keep=date S_series VS_SERIES);
where year(date) = 1957 and (month(date) = 6 or month(date) = 8) ;
estimate = S_series;
std = sqrt( VS_SERIES );
run;
data table5;
merge data1(keep=date logair) table5;
where year(date) = 1957 and (month(date) = 6 or month(date) = 8) ;
by date;
run;
proc print data=table1 noobs;
format _numeric_ 8.3;
run;
proc print data=table2 noobs;
format _numeric_ 8.3;
format date monyy.5;
run;
proc print data=table3 noobs;
format _numeric_ 8.3;
format date monyy.5;
run;
proc print data=table4 noobs;
format _numeric_ 8.3;
format date monyy.5;
run;
proc print data=table5 noobs;
format _numeric_ 8.3;
format date monyy.5;
run;