Command Reference : Command Reference
  
 
import
Imports data from a foreign file or a previously saved workfile into the current default workfile. The import command lets you perform four different types of data importing: dated reads, match-merge reads, sequential reads, and appends.
Dated imports can only be performed if the destination workfile is a dated workfile. You must specify the date structure of the source data as part of the import command. EViews will then match the date structure of the source with that of the destination, and perform frequency conversion if necessary.
Match-merge imports require both a source ID series and a destination ID series. EViews will read the source data into the destination workfile based upon matched values of the two ID series.
Sequential imports will read the source data into the destination workfile by matching the first observation of the source file to the first observation in the destination workfile's current sample, then the second observation of the source with the second observation in the destination's current sample, and so on.
Appended imports simply append the source data to the end of the destination workfile.
Syntax
The general form of the import command is:
import([type=], options) source_description import_specification [@smpl smpl_string] [@genr genr_string] [@rename rename_string]
where the syntax for import_specification depends on whether the read is a dated ( “Dated Imports”), match-merge ( “Match-Merge Import”), sequential ( “Sequential Read”), or appended import ( “Appended Read”).
Source_description should contain a description of the file from which the data is to be imported. The specification of the description is usually just the path and file name of the file, however you can also specify more precise information. See wfopen for more details on the specification of source_description.
The optional “type=” option may be used to specify a source type. For the most part, you should not need to specify a “type=” option as EViews will automatically determine the type from the filename. The following table summaries the various source formats and along with the corresponding “type=” keywords:
 
 
Option Keywords
Access
“access”
Aremos-TSD
“a”, “aremos”, “tsd”
Binary
“binary”
dBASE
“dbase”
Excel (through 2003)
“excel”
Excel 2007 (xml)
“excelxml”
EViews Workfile
---
Gauss Dataset
“gauss”
GiveWin/PcGive
“g”, “give”
HTML
“html”
Lotus 1-2-3
“lotus”
ODBC Dsn File
“dsn”
ODBC Query File
“msquery”
ODBC Data Source
“odbc”
MicroTSP Workfile
“dos”, “microtsp”
MicroTSP Mac Workfile
“mac”
RATS 4.x
“r”, “rats”
RATS Portable / TROLL
“l”, “trl”
SAS Program
“sasprog”
SAS Transport
“sasxport”
SPSS
“spss”
SPSS Portable
“spssport”
Stata
“stata”
Text / ASCII
“text”
TSP Portable
“t”, “tsp”
The optional @smpl keyword may be used to specify that data is only imported for the observations specified by smpl_string. By default, the import will use all of the observations in the workfile. If @smpl is included, but no smpl_string is included, then the current default workfile sample is used.
The optional @genr keyword may be used to generate a new series in the workfile as part of the import procedure. genr_string may be any valid series creation expression, and can be an expression based upon one of the imported series. See genr for information on valid expressions.
The optional @rename keyword may be used to rename some of the imported series where rename_string contains pairs of old object names followed by the new names. See rename for additional discussion.
In the remainder of this discussion, we examine each of the different import types in greater depth.
Dated Imports
The syntax for a dated import command is:
import([type=], options) source_description @freq frequency start_date [@smpl smpl_string] [@genr genr_string] [@rename rename_string]
The import_specification consists of the @freq keyword followed by a frequency argument specifying the frequency of the source data and a start_date to specify the starting date of the source data. See wfcreate for details on the forms that frequency may take.
Basic Options
 
resize
Extend the destination workfile (if necessary) to include the entire range of the source data.
link
Link the object to the source data so that the values can be refreshed at a later time.
mode=arg (default=“o”)
Set the behavior for handling name conflicts when an imported series already exists in the destination workfile. arg can be “o” (Completely replace existing series with source series. Note that values outside of the range of the source data will be overwritten with NAs), “u” (Overwrite existing series only for values within the range of the source data. Destination values outside of the source range will be unchanged), “ms” (Overwrite existing series, unless source value is an NA, in which case keep destination values), “md” (Only overwrite NA values in destination series), “r” (rename any conflicts), or “p” (do not import any series which have a name conflict).
page=page_name
Optional name for the page into which the data should be imported.
tr=integer
Truncate long series names to integer characters. The default value of integer is 24.
prompt
Force the dialog to appear from within a program.
Frequency Conversion Options
The following options control the frequency conversion method when copying series and group objects into a workfile page and converting from low to high frequency:
 
c=arg
Low to high conversion methods: “r” or “repeata” (constant match average), “d” or “repeats” (constant match sum), “q” or “quada” (quadratic match average), “t” or “quads” (quadratic match sum), “linearf” (linear match first), “i” or “linearl” (linear match last), “cubicf” (cubic match first), “c” or “cubicl” (cubic match last), “pointf” (point first), “pointl” (point last).
When importing data from a higher frequency source into a lower frequency destination:
 
c=arg
High to low conversion methods removing NAs: “a” (average of the nonmissing observations), “s” (sum of the nonmissing observations), “f” (first nonmissing observation), “l” (last nonmissing observation), “x” (maximum nonmissing observation), “m” (minimum nonmissing observation).
High to low conversion methods propagating NAs: “an” or “na” (average, propagating missings), “sn” or “ns” (sum, propagating missings), “fn” or “nf” (first, propagating missings), “ln” or “nl” (last, propagating missings), “xn” or “nx” (maximum, propagating missings), “mn” or “nm” (minimum, propagating missings).
Examples
import c:\temp\quarterly.xls @freq q 1990
will import the file QUARTERLY.XLS into the current default workfile. The source file has a quarterly frequency, starting at 1990.
import(c=s) c:\temp\quarterly.xls range="GDP_SHEET" @freq q 1990 @rename gdp_per_capita gdp
will import from same file, but instead will use the data on the Excel sheet called “GDP_SHEET”, and will rename the series GDP_PER_CAPITA to GDP. A frequency conversion method using the sum of the nonmissing observations is used rather than the default average.
import(mode=p) c:\temp\annual.txt @freq a 1990 @smpl 1994 1996
will import data from a text file called annual.txt, into the current default workfile. Any data in the text file that already exists in the destination workfile will be ignored, and for the remaining series, only the dates between 1994 and 1996 will be imported.
Additionally, specifying the “tr” option causes EViews 10 to truncate long series names to 24 characters (by default) instead of 300. This will let programs written for EViews 9 continue to work with EViews 10:
fetch(d=eia, link, tr) coal.average_employees.al-tot.a
The “tr” option can also be set to a number between 0 and 300:
fetch(d=eia, link, tr=20) coal.average_employees.al-tot.a
Match-Merge Import
Syntax
import(options) source_description @id id @destid destid [@smpl smpl_string] [@genr genr_string] [@rename rename_string]
The import_specification consists of the @id keyword and at least one ID series in the source file, followed by the @destid keyword and at least one ID series in the destination workfile. The two sets of ID series should be compatible, in that they should contain a subset of identical values that provide information on how observations from the two files should be matched. If one of the ID series is a date series, you should surround it with the @date( ) keyword.
Options
 
resize
Extend the destination workfile (if necessary) to include the entire range of the source data.
link
Link the object to the source data so that the values can be refreshed at a later time.
mode=arg (default=“o”)
Set the behavior for handling name conflicts when an imported series already exists in the destination workfile. arg can be “o” (Completely replace existing series with source series. Note that values outside of the range of the source data will be overwritten with NAs), “u” (Overwrite existing series only for values within the range of the source data. Destination values outside of the source range will be unchanged), “ms” (Overwrite existing series, unless source value is an NA, in which case keep destination values), “md” (Only overwrite NA values in destination series), “r” (rename any conflicts), or “p” (do not import any series which have a name conflict).
nacat
Treat “NA” values as a category when copying using general match merge operations.
propnas
Propogate NAs / partial periods evaluate to NAs when converting.
c=arg
Set the match merge contraction method.
If you are importing a numeric source series by general match merge, the argument can be one of: “mean”, “med”
(median), “max”, “min”, “sum”, “sumsq” (sum-of squares), “var” (variance), “sd” (standard deviation), “skew” (skewness), “kurt” (kurtosis), “quant” (quantile, used with “quant=” option), “obs” (number of observations), “nas” (number of NA values), “first” (first observation in group), “last” (last observation in group), unique” (single unique group value, if present), “none” (disallow contractions).
If importing an alpha series, only the non-summary methods “max”, “min”, “obs”, “nas”, first”, “last”, “unique” and “none” are supported.
For importing of numeric series, the default contraction method is “c=mean”; for copying of alpha series, the default is “c=unique”.
page=page_name
Optional name for the page into which the data should be imported.
prompt
Force the dialog to appear from within a program.
Most of the conversion options should be self-explanatory. As for the others: “first” and “last” give the first and last non-missing observed for a given group ID; “obs” provides the number of non-missing values for a given group; “nas” reports the number of NAs in the group; “unique” will provide the value in the source series if it is the identical for all observations in the group, and will return NA otherwise; “none” will cause the import to fail if there are multiple observations in any group—this setting may be used if you wish to prohibit all contractions.
Examples
import(c=max, type=excel) c:\data\stateunemp.xls @id states @destid states
will import the file STATEUNEMP.XLS using the ID series STATES in both files as the match merge criteria. The maximum value is used as a contraction method. Note that although the “type=excel” option was used, it was not necessary since EViews will automatically detect the file type based on the file's extension (.xls).
import c:\data\stategdp.txt colhead=3 delim=comma @id states @date(year) @destid states @date
will import the file STATEGDP.TXT, specifying that there are three lines of column headers, and the delimiter for the text file is a comma. The series STATES is used as an ID series in both files, along with a date series (YEAR for the source file, and the default EViews date series, @DATE, for the destination workfile). Note that this type of import, with both a cross-section ID and a date ID is most commonly employed for importing data into panel workfiles.
import c:\data\cagdp.xls @id states @date(year) @destid states @date @genr states="CA"
will import the file CAGDP.XLS into the current workfile. In this particular case the source file is a time series file for a single state, California. Since the importing is being done into a panel workfile, the @genr keyword is used to generate a series containing the state identifier, CA, which is then used as the source ID.
Sequential Read
Syntax
import(options) source_description [@smpl smpl_string] [@genr genr_string] [@rename rename_string]
No import_specification is required for a sequential read.
Options
 
resize
Extend the destination workfile (if necessary) to include the entire range of the source data.
link
Link the object to the source data so that the values can be refreshed at a later time.
mode=arg (default=“o”)
Set the behavior for handling name conflicts when an imported series already exists in the destination workfile. arg can be “o” (Completely replace existing series with source series. Note that values outside of the range of the source data will be overwritten with NAs), “u” (Overwrite existing series only for values within the range of the source data. Destination values outside of the source range will be unchanged), “ms” (Overwrite existing series, unless source value is an NA, in which case keep destination values), “md” (Only overwrite NA values in destination series), “r” (rename any conflicts), or “p” (do not import any series which have a name conflict).
page=page_name
Optional name for the page into which the data should be imported.
prompt
Force the dialog to appear from within a program.
Examples
import(resize) sales.dta @smpl @all
will import the Stata file SALES.DTA into the current workfile, using the entire workfile range. If the sales.dta file contains more observations that the current workfile, the current workfile is resized to accommodate the extra rows of data.
Appended Read
Syntax
import(options) source_description @append [@genr genr_string] [@rename rename_string]
The import_specification consists of the @append keyword. Note that the @smpl keyword is not supported for appended import.
Options
 
link
Link the object to the source data so that the values can be refreshed at a later time.
mode=arg (default=“o”)
Set the behavior for handling name conflicts when an imported series already exists in the destination workfile. arg can be “o” (Completely replace existing series with source series. Note that values outside of the range of the source data will be overwritten with NAs), “r” (rename any conflicts), or “p” (do not import any series which have a name conflict).
page=page_name
Optional name for the page into which the data should be imported.
prompt
Force the dialog to appear from within a program.
Examples
import(page=demand) demand.txt @append
will append the text file, DEMAND.TXT, to the bottom of the page “demand” in the current workfile.
Cross-references
See “Workfile Basics” for a discussion of workfiles.
See also wfopen, copy, pageload, read, fetch, wfsave, and pagesave.