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

'create workfile
workfile x12ex21 m 1964 1995

'read data
%datafile = @runpath + "x12ex2.dat"
read(t,d=s,mult,norect,dropstrings) "{%datafile}" x

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

'-----------------------------------------------------------------------
'visually check calendar month heteroskedasticity
'-----------------------------------------------------------------------

'set adjustment sample
smpl 1982:1 @last

freeze(fig1) x.seasplot
show fig1

'-----------------------------------------------------------------------
'run mw1fam0.spc (3x9 filter only)
'-----------------------------------------------------------------------

'set adjustment sample
smpl 1982:1 @last

'call x12
%specfile = @runpath + "ev_mw1fam0.spc"
freeze(tab1) x.x12(ns, gdir="{%path}", sfile="{%specfile}")

'set history sample
smpl 1992:1 @last

'read history of seasonally adjusted from evx12tmp.fce dumped in {%path}
read(d=t,mult,rect,skiprow=2) "{%path}evx12tmp.sae" date x0cnc x0fin

'read history of percent change in seasonally adjusted from evx12tmp.fce dumped in {%path}
read(d=t,mult,rect,skiprow=2) "{%path}evx12tmp.che" date dx0cnc dx0fin

'-----------------------------------------------------------------------
'run mw1fam1.spc (3x9 and 3x5 filters)
'-----------------------------------------------------------------------

'set adjustment sample
smpl 1982:1 @last

'call x12
%specfile = @runpath + "ev_mw1fam1.spc"
freeze(tab2) x.x12(ns, gdir="{%path}",  sfile="{%specfile}")

'set history sample
smpl 1992:1 @last

'read history of seasonally adjusted from evx12tmp.fce dumped in {%path}
read(d=t,mult,rect,skiprow=2) "{%path}evx12tmp.sae" date x1cnc x1fin

'read history of percent change in seasonally adjusted from evx12tmp.fce dumped in {%path}
read(d=t,mult,rect,skiprow=2) "{%path}evx12tmp.che" date dx1cnc dx1fin

'-----------------------------------------------------------------------
'run mw1fam.spc (3x9 and 3x5 filters with calendarsigma)
'-----------------------------------------------------------------------

'set adjustment sample
smpl 1982:1 @last

'call x12
%specfile = @runpath + "ev_mw1fam.spc"
freeze(tab3) x.x12(ns, gdir="{%path}", sfile="{%specfile}")

'set history sample
smpl 1992:1 @last

'read history of seasonally adjusted from evx12tmp.fce dumped in {%path}
read(d=t,mult,rect,skiprow=2) "{%path}evx12tmp.sae" date x2cnc x2fin

'read history of percent change in seasonally adjusted from evx12tmp.fce dumped in {%path}
read(d=t,mult,rect,skiprow=2) "{%path}evx12tmp.che" date dx2cnc dx2fin

'-----------------------------------------------------------------------
'compare revisions
'-----------------------------------------------------------------------

group g1
group g2
for !i=0 to 2
	series revs{!i} = (x{!i}fin-x{!i}cnc)/x{!i}cnc
	g1.add revs{!i}
	series revd{!i} = (dx{!i}fin-dx{!i}cnc)/dx{!i}cnc
	g2.add revd{!i}
next

freeze(gra1) g1.line
'add title
gra1.addtext(t) Revisions of seasonal adjusted values
show gra1

freeze(gra2) g2.line
'add title
gra2.addtext(t) Revisions of percent change in seasonal adjusted values
show gra2

