# X12

## Important limitation of X12:

The currently shipping X12 version 0.2.7 has the following limitations. First, EViews must be executed from a directory that has a proper letter drive name. If you are running EViews over the network, make sure the server directory is mapped to a letter drive on your local machine. Second, for options that require path information, there is a limitation on the path length. Specifically, X12 will not recognize long paths that have more than four subdirectories. If you encounter problems running the example files below, make sure that this restriction is satisfied (in particular watch out for the model file used for auto model selection and the gdir= option described below).

## Use of external spec file

The following programs illustrate some advanced usage of X12 that cannot be done through the dialog. Most of these example programs use an external spec file. A spec file should be written in the X12 syntax, except for the following:

- it should not contain the series or composite spec
- any reference to an external file in the spec file should include the full path to the file in DOS short format.

## X12 graphics metafiles

These programs also illustrate the use of the `gdir=` option to dump the X12 graphics metafiles into the specified directory. All graphics metafiles will have the name evx12tmp with different extensions. The file evx12tmp.gmt contains a description of all files returned in gdir=, which should be compared with Table 2-2, pp.12-13 of the X12 Reference Manual.

The directory specified by the `gdir=` option should not be the same as the working directory used by EViews since it may overwrite other saved files with the same name. You can get the working directory used by EViews by a call to the @temppath command. Make sure to set the gdir= path to a writeable directory.

## Sample programs

Most of these programs are based on the example programs provided by the Census as part of the distribution of their X12 program.

- Obtaining forecasts from X12 (x12fcst.prg)

- History of sum-of-squared forecast errors (x12ex11.prg)
- Seasonal heteroskedasticity (x12ex21.prg)
- Series with no stable seasonality (x12ex41.prg)
- Adjustment of a short series (x12ex51.prg)
- Subsample estimation (x12ex61.prg)
- Residual spectrum peaks (x12ex71.prg)
- Trading day effects (x12ex72.prg)
- Subjective preadjustment (x12ex81.prg)
- Trend extraction (x12ex91.prg)

## Obtaining forecasts from X12

This program illustrates two methods of obtaining forecasts from X12. The first method is to simply use the `f` and `flead=` options in the `x12` proc. This method is simple but returns forecasts only up to one year (even if you set `flead=` to more than one year). If you need longer forecasts as specified by `flead=`, use the `gdir=` option and read in the data file returned by X12 yourself. The data files returned in `gdir` contain forecasts up to `flead` periods and confidence bounds (only for the data series).

    'obtaining forecasts from x12
    'version 4
    '11/16/2000 h

    workfile x12ts4 m 1949:01 1970:4

    series x
    x.fill 112, 118, 132, 129, 121, 135, 148, 148, 136, 119, 104, 118, 115, 126, 141, 135, 125, 149, 170, 170, 158, 133, 114, 140, 145, 150, 178, 163, 172, 178, 199, 199, 184, 162, 146, 166, 171, 180, 193, 181, 183, 218, 230, 242, 209, 191, 172, 194, 196, 196, 236, 235, 229, 243, 264, 272, 237, 211, 180, 201, 204, 188, 235, 227, 234, 264, 302, 293, 259, 229, 203, 229, 242, 233, 267, 269, 270, 315, 364, 347, 312, 274, 237, 278, 284, 277, 317, 313, 318, 374, 413, 405, 355, 306, 271, 306, 315, 301, 356, 348, 355, 422, 465, 467, 404, 347, 305, 336, 340, 318, 362, 348, 363, 435, 491, 505, 404, 359, 310, 337, 360, 342, 406, 396, 420, 472, 548, 559, 463, 407, 362, 405, 417, 391, 419, 461, 472, 535, 622, 606, 508, 461, 390, 432

    '------------------------------------------------------------------------------
    'simplest method: returns forecasts only up to one year
    '------------------------------------------------------------------------------

    smpl 1949:01 1960:12
    freeze(tab1) x.x12(mode=l, arima="(0 1 1)(0 1 1)", f, flead=36, save="b1 d10 d11 d12 d13") x1
    'show tab1

    'split out-of-sample from in-sample
    series x1 = x
    series x1f
    series x1f_sf

    smpl 1961:01 1963:12
    x1 = x1_b1
    x1f = x1_b1
    x1f_sf = x1_sf

    'plot
    smpl 1960:01 1963:12
    graph g1a.line x1 x1f
    g1a.setelem(1) legend(raw series)
    g1a.setelem(2) legend(forecast)

    graph g1b.line x1_sf x1f_sf
    g1b.setelem(1) legend(seasonal factors)
    g1b.setelem(2) legend(forecast)

    graph g1.merge g1a g1b
    g1.options size(8,2)
    g1.align(1,0,1.0)
    g1.addtext(0.1,-0.1) Simple forecasts using f option
    show g1

    '------------------------------------------------------------------------------
    'gdir= option dumps files for graphics which has longer forecasts and confidence
    'bounds (only for raw data). you need to read the data back yourself using the
    'read command. look at the file evx12tmp.gmt file and Table 2-2 of the X12 manual
    'for a description of each file in gdir
    '------------------------------------------------------------------------------

    'set paths to read output data files
    %gdir_path = @temppath + "\x12graphs\"

    smpl 1949:01 1960:12
    freeze(tab2) x.x12(gdir="{%gdir_path}", mode=l, arima="(0 1 1)(0 1 1)", f, flead=36, save="b1 d10 d11 d12 d13") x2
    'show tab2

    'read forecasts from file in %gdir_path
    smpl 61:01 @last
    read(skiprow=2,skipcol=1) "{%gdir_path}evx12tmp.fct" x2f x2f_low x2f_upp
    smpl 49:01 @last
    read(skiprow=2,skipcol=1) "{%gdir_path}evx12tmp.d10" x2_sf

    'split out-of-sample from in-sample
    smpl 1949:01 1960:12
    series x2 = x
    series x2f_sf

    smpl 1961:01 1963:12
    x2 = x2_b1
    x2f_sf = x2_sf

    'plot
    smpl 1960:01 1963:12
    graph g2a.line x2 x2f x2f_low x2f_upp
    g2a.options linepat
    g2a.setelem(1) legend(raw series) lcolor(blue) lpat(solid)
    g2a.setelem(2) legend(forecast) lcolor(red) lpat(solid)
    g2a.setelem(3) legend(95% lower bound) linecolor(255,150,255) lpat(dash1)
    g2a.setelem(4) legend(95% upper bound) linecolor(255,150,255) lpat(dash1)

    graph g2b.line x2_sf x2f_sf
    g2b.setelem(1) legend(seasonal factors)
    g2b.setelem(2) legend(forecast)

    graph g2.merge g2a g2b
    g2.options size(8,2)
    g2.align(1,0,1.0)
    g2.addtext(0.1,-0.1) Forecasts read from gdir= files
    show g2

## History of sum-of-squared forecast errors

This program illustrates how to choose between two different adjustment procedures by comparing the history of sum-of-squared forecast errors. See example1.txt for further details.

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

    'create workfile
    workfile x12ex11 m 1967 1999

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

    'estimation subsample
    sample smod 1983:1 @last

    'set path to dump x12 graphics metafiles
    '*network version users must replace with writeable path*
    %path = @runpath + "tmp\"
    '%path = "d:\ev4prg\tmp\"

    '-----------------------------------------------------------------------
    'run shoersm1.spc (x11easter adj)
    '-----------------------------------------------------------------------

    'set adjustment sample
    smpl 1972:1 @last

    'call x12
    %specfile = @runpath + "ev_shoersm1.spc"
    freeze(tab1) x.x12(modelsmpl=smod, ns, save="h1", gdir="{%path}", sfile="{%specfile}")
    'show tab1

    'read history of sum of squared forecast errors
    'from evx12tmp.fce dumped in {%path}

    smpl 1991:2 @last
    read(d=t,mult,rect,skiprow=2) "{%path}evx12tmp.fce" date x1fce01 x1fce12

    '-----------------------------------------------------------------------
    'run shoersm2.spc (x11easter adj)
    '-----------------------------------------------------------------------

    'set adjustment sample
    smpl 1972:1 @last

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

    'show tab2

    'read history of sum of squared forecast errors
    'from evx12tmp.fce dumped in {%path}

    smpl 1991:2 @last
    read(d=t,mult,rect,skiprow=2) "{%path}evx12tmp.fce" date x2fce01 x2fce12

    '-----------------------------------------------------------------------
    'compare adjustments via difference of forecast errors
    '-----------------------------------------------------------------------

    series diff01 = x2fce01 - x1fce01
    series diff12 = x2fce12 - x1fce12
    diff01.displayname lag 1
    diff12.displayname lag 12

    group g1 diff01 diff12
    freeze(graph1) g1.line

    'add title
    graph1.addtext(t) Difference of sum-of-squared forecast errors (reg_easter - x11easter)

    'add zero line
    graph1.draw(dashline,left) 0
    show graph1

## Seasonal heteroskedasticity

This program uses season specific seasonal filters to deal with seasonal heteroskedasticity. See example2.txt for further details.

    '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
    '*network version users must replace with writeable path*
    %path = @runpath + "tmp\"
    '%path = "d:\ev4prg\tmp\"

    '-----------------------------------------------------------------------
    '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

## Series with no stable seasonality

Example of a series with no stable seasonality and unsuitable for seasonal adjustment. The program illustrates how to plot the spectrum of the raw data series. See example4.txt for further details.

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

    include sub_readx12spectrum.prg

    'create workfile
    workfile x12ex41 m 1979 1995

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

    'set path to dump x12 graphics metafiles
    '*network version users must replace with writeable path*
    %path = @runpath + "tmp\"
    '%path = "d:\ev4prg\tmp\"

    '-----------------------------------------------------------------------
    'visually check seasonality
    '-----------------------------------------------------------------------

    'set adjustment sample
    smpl 1980:1 @last

    freeze(fig1) x.seasplot
    show fig1

    freeze(fig2) x.seasplot(m)
    show fig2

    '-----------------------------------------------------------------------
    'run m1gold.spc
    '-----------------------------------------------------------------------

    'set adjustment sample
    smpl 1980:1 @last

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

    'read seasonally adjusted series from evx12tmp.d11 dumped in {%path}
    read(d=t,mult,rect,skiprow=2) "{%path}evx12tmp.d11" date x_d11

    'read seasonal factors from evx12tmp.d10 dumped in {%path}
    read(d=t,mult,rect,skiprow=2) "{%path}evx12tmp.d10" date x_d10

    'plot spectrum of original series from evx12tmp.sp0 dumped in {%path}
    %fname = %path + "evx12tmp.sp0"
    %gname = "graph1"
    call sub_readx12spectrum(%fname, %gname, 12)
    {%gname}.addtext(t) Spectrum of original series
    show {%gname}

## Adjustment of a short series

This example illustrates seasonal adjustment of a short series. For short series, specification of the regARIMA model (by adding or changing regressors) can have a signficant impact on other coefficent estimates and on the seasonal factors. See example5.txt for further details.

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

    'create workfile
    workfile x12ex51 q 1990 1998

    'fill series
    series x
    x.fill 97.49, 96.11, 106.17, 100.23, 91.53, 103.51, 107.44, 101.64, 95.47, 101.72, 103.71, 101.02, 98.73, 107.06, 109.16, 106.77, 103.40, 110.38, 115.79, 116.85, 114.18, 117.46, 116.99, 116.64, 112.57, 120.10, 123.26, 122.17, 116.84, 124.82, 126.79, 124.81, 118.13

    'set path to dump x12 graphics metafiles
    '*network version users must replace with writeable path*
    %path = @runpath + "tmp\"
    '%path = "d:\ev4prg\tmp\"

    '-----------------------------------------------------------------------
    'use spec file brazgnp.spc
    '-----------------------------------------------------------------------

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

    'read seasonally adjusted series from evx12tmp.d11 dumped in {%path}
    read(d=t,mult,rect,skiprow=2) "{%path}evx12tmp.d11" date x1_sa

    'read seasonal factors from evx12tmp.d10 dumped in {%path}
    read(d=t,mult,rect,skiprow=2) "{%path}evx12tmp.d10" date x1_sf

    '-----------------------------------------------------------------------
    'replicate brazgnp.spc
    '-----------------------------------------------------------------------

    'call x12 without external spec file
    freeze(tab2) x.x12(gdir="{%path}", save="d10 d11", reg="ao1990.2 tdnolpyear", arima="(0 1 1)(0 1 1)", check, mode=a, flead=4) x2

    'should all be zeros
    show x1_sa-x2_sa x1_sf-x2_sf

## Subsample estimation

This example illustrates the (beneficial) effect of fitting the regARIMA model to a subsample of the adjustment sample. See example6.txt for further details.

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

    'create workfile
    workfile x12ex61 m 1986 1996

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

    'set path to dump x12 graphics metafiles
    '*network version users must replace with writeable path*
    %path = @evpath + "tmp\"
    '%path = "d:\ev4prg\tmp\"

    '-----------------------------------------------------------------------
    'replicate index0.spc (full sample estimation)
    '-----------------------------------------------------------------------

    'call x12 without external spec file
    freeze(tab0) x.x12(gdir="{%path}", save="d10", reg="ao1990.4", arima="([1,6] 1 0)(0 1 1)", check, tf=0, flead=36) x0

    '-----------------------------------------------------------------------
    'replicate index.spc (subsample estimation)
    '-----------------------------------------------------------------------

    'call x12 without external spec file
    freeze(tab1) x.x12(gdir="{%path}", save="d10 d11", reg="ao1990.4", arima="([1,6] 1 0)(0 1 1)", check, tf=0, flead=36, modelsmpl="1989.1 @last") x1

## Residual spectrum peaks

This example illustrates the use of the residual spectrum as a diagnostic tool and methods to deal with peaks left in the residual spectrum. See example7.txt for further details.

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

    include sub_readx12spectrum.prg

    'create workfile
    workfile x12ex71 m 1980 1996

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

    'set path to dump x12 graphics metafiles
    '*network version users must replace with writeable path*
    %path = @runpath + "tmp\"
    '%path = "d:\ev4prg\tmp\"

    '-----------------------------------------------------------------------
    'default run (full sample)
    '-----------------------------------------------------------------------

    'call x12 without external spec file
    freeze(tab0) x.x12(gdir="{%path}", save="d10", check, tf=0, flead=24, outlier, plotspectra, amdl=f) x0

    'make copy of diagnostic spetra (will be overwritten)
    copy gr_x0_sp gr0spe
    show gr0spe

    'plot regARIMA resid spectrum
    %fname = %path + "EVX12TMP.spr"
    %gname = "g0res"
    !freq = 12
    call sub_readX12Spectrum(%fname, %gname, !freq)
    {%gname}.addtext(t) Spectrum of regARIMA residuals (full sample)
    show {%gname}

    '-----------------------------------------------------------------------
    'default run (subsample as in cetg0.spc)
    '-----------------------------------------------------------------------

    smpl 1986:1 @last
    'call x12 without external spec file
    freeze(tab1) x.x12(gdir="{%path}", save="d10", check, tf=0, flead=24, outlier, plotspectra, amdl=f) x1

    'make copy of diagnostic spetra (will be overwritten)
    copy gr_x1_sp gr1spe
    show gr1spe

    'plot regARIMA resid spectrum
    %fname = %path + "EVX12TMP.spr"
    %gname = "g1res"
    !freq = 12
    call sub_readX12Spectrum(%fname, %gname, !freq)
    {%gname}.addtext(t) Spectrum of regARIMA residuals (subsample)
    show {%gname}

## Trading day effects

This example illustrates and compares several methods to deal with trading day effects. See example7.txt for further details.

    '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
    '*network version users must replace with writeable path*
    %gpath = @runpath + "tmp\"
    '%gpath = "d:\ev4prg\tmp\"

    '-----------------------------------------------------------------------
    '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

## Subjective preadjustment

This example illustrates preadjustment using exogenous information to apply a transformation to the data. See example8.txt for further details. Warning: this program uses spec files that have built-in path names for the data file. You must modify these data paths in the two spec files ev_beauto.spc and ev_beauto0.spc in order to run this example program.

    'eviews x12 interface
    'replicate example 8 provided by census
    'warning: data file path hard-coded in .spc files
    'version 4
    'last checked and revised 10/27/2000 h

    'create workfile
    workfile x12ex81 m 1972 1989

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

    'set path to dump x12 graphics metafiles
    '*network version users must replace with writeable path*
    %path = @runpath + "tmp\"
    '%path = "d:\ev4prg\tmp\"

    '-----------------------------------------------------------------------
    'no preadjustment in transform
    '-----------------------------------------------------------------------

    'call x12 with external spec file
    smpl @all
    %specfile = @runpath + "ev_beauto0.spc"
    freeze(tab0) x.x12(gdir="{%path}", ns, sfile="{%specfile}") x0

    'read history of logl and AIC from evx12tmp.lkh dumped in {%gpath}
    smpl 1979:1 @last
    read(d=t,mult,rect,skiprow=2) "{%path}evx12tmp.lkh" date x0logl x0aic

    '-----------------------------------------------------------------------
    'with preadjustment in transform
    '-----------------------------------------------------------------------

    'read subjective adjustment factors
    smpl @all
    %datafile = @runpath + "beauto.adj"
    read(norect,dropstrings) "{%datafile}" xadj

    'display subjective factors
    xadj.displayname subjective factors (hybrid?)
    freeze(gra_adj) xadj.line
    show gra_adj

    'call x12 with external spec file
    smpl @all
    %specfile = @runpath + "ev_beauto.spc"
    freeze(tab1) x.x12(gdir="{%path}", ns, sfile="{%specfile}") x1

    'read history of logl and AIC from evx12tmp.lkh dumped in {%gpath}
    smpl 1979:1 @last
    read(d=t,mult,rect,skiprow=2) "{%path}evx12tmp.lkh" date x1logl x1aic

    '-----------------------------------------------------------------------
    'compare effect of preadjustment
    '-----------------------------------------------------------------------

    'AIC difference
    series adiff = x0aic - x1aic
    adiff.displayname no_adj_aic - adj_aic
    freeze(gra2) adiff.line
    gra2.addtext(t) History of AIC difference
    show gra2

    series ldiff = x0logl - x1logl
    ldiff.displayname no_adj_logl - adj_logl
    freeze(gra3) ldiff.line
    gra3.addtext(t) History of logl difference
    show gra3

## Trend extraction

This example illustrates how to extract an estimate of the trend from a seasonally adjusted series. Note how the estimate of the trend differs depending on the `type=trend` option in the x11 spec. See example9.txt for further details.

    'eviews x12 interface
    'replicate example 9 provided by census
    'trend extraction of seasonally adjusted series
    'version 4
    'last checked and revised 10/27/2000 h

    'create workfile
    workfile x12ex91 m 1981 1997

    'read series
    %datafile = @runpath + "usstrts2.dat"
    read(norect,dropstrings) "{%datafile}" x
    'precision=1
    x = x/10

    'set path to dump x12 graphics metafiles
    '*network version users must replace with writeable path*
    %path = @runpath + "tmp\"
    '%path = "d:\ev4prg\tmp\"

    '-----------------------------------------------------------------------
    'seasonal adjustment and trend
    '-----------------------------------------------------------------------

    'call x12
    smpl 84:3 @last
    %specfile = @runpath + "ev_strtsnsd0.spc"
    freeze(tab0) x.x12(gdir="{%path}", ns, sfile="{%specfile}") x0

    'read trend-cycle from evx12tmp.d12 dumped in {%path}
    read(d=t,mult,rect,skiprow=2) "{%path}evx12tmp.d12" date x0d12

    '-----------------------------------------------------------------------
    'only trend
    '-----------------------------------------------------------------------

    smpl 84:3 @last
    %specfile = @runpath + "ev_strtsnsd.spc"
    freeze(tab1) x.x12(gdir="{%path}", ns, sfile="{%specfile}") x1

    'read trend-cycle from evx12tmp.d12 dumped in {%path}
    read(d=t,mult,rect,skiprow=2) "{%path}evx12tmp.d12" date x1d12

    '-----------------------------------------------------------------------
    'display difference
    '-----------------------------------------------------------------------

    series tcdiff = x0d12 - x1d12
    tcdiff.displayname adj_trend - no_adj_trend
    freeze(gra1) tcdiff.line
    show gra1