'eviews x12 interface
'replicate example 7 provided by census
'version 4
'last checked and revised 10/27/2000 h

'create workfile
workfile x12ex72 m 1980 1996

'read series
%datafile = @runpath + "s0b566.dat"
read(norect,dropstrings) "{%datafile}" x

'set path to dump x12 graphics metafiles
'*must set to writeable path*
%gpath = @temppath + "\x12graphs\"

'-----------------------------------------------------------------------
'compare various trading day correction methods
'-----------------------------------------------------------------------

!i=0
for %sfile ev_cetg0.spc ev_cetg1.spc ev_cetg2.spc ev_cetg3.spc ev_cetgengq.spc
	statusline running spec !i...

	smpl 1986:1 @last

	'call x12 with external spec file
	%sname = @runpath + %sfile
	freeze(tab{!i}) x.x12(ns, gdir="{%gpath}", sfile="{%sname}") x{!i}

	'read history of sum of squared forecast errors from evx12tmp.fce dumped in {%gpath}
	smpl 1992:2 @last
	read(d=t,mult,rect,skiprow=2) "{%gpath}evx12tmp.fce" date x{!i}fce01 x{!i}fce12

	'read history of logl and AIC from evx12tmp.lkh dumped in {%gpath}
	smpl 1992:1 @last
	read(d=t,mult,rect,skiprow=2) "{%gpath}evx12tmp.lkh" date x{!i}logl x{!i}aic

	'increment index number
	!i = !i + 1
next

'-----------------------------------------------------------------------
'plot history of forecast errors from various trading day correction methods
'-----------------------------------------------------------------------

group g01
group g12
for !i=0 to 4
	g01.add x{!i}fce01 
	g12.add x{!i}fce12
next

freeze(gra01) g01.line
freeze(gra12) g12.line

'change graph labels
for %name 01 12
	gra{%name}.element(1) legend(none)
	gra{%name}.element(2) legend(tdstock)
	gra{%name}.element(3) legend(td)
	gra{%name}.element(4) legend(td1coef)
	gra{%name}.element(5) legend(census final)

	gra{%name}.element(5) symbol(circle)

	gra{%name}.legend columns(1) position(right)
	gra{%name}.addtext(t) Sum of squared forecast errors (lag {%name})
next

'gra01.addtext(t) Sum of squared forecast errors (lag 1)
'gra12.addtext(t) Sum of squared forecast errors (lag 12)

show gra01
show gra12

