Command Reference : Command Reference : wfsave : Excel Files
  
 
wfsave
Save the default workfile as an EViews workfile (.wf1 file) or as a foreign file or data source.
Syntax
wfsave(options) [path\]filename
wfsave(options) source_description [nonames] [@keep keep_list] [@drop drop_list] [@keepmap keepmap_list] [@dropmap dropmap_list] [@smpl smpl_spec]
wfsave(options) source_description table_description [nonames] [@keep keep_list] [@drop drop_list] [@keepmap keepmap_list] [@dropmap dropmap_list] [@smpl smpl_spec]
saves the active workfile in the specified directory using filename. By default, the workfile is saved as an EViews workfile, but options may be used to save all or part of the active page in a foreign file or data source.
When saving to a foreign data file, the basic specification consists of a “type=” option and source_description and table_description arguments which specify the format of the foreign data file. See below for details on source_description and table_description.
The remaining optional elements specify the actual elements to be saved.
Options
Workfile (WF1) Save Options
 
1
Save using single precision.
2
Save using double precision.
c
Save compressed workfile (not compatible with EViews versions prior to 5.0).
Workfile (WF2) Save Options
 
jf
Save JSON with formatting making it easier to read. Increases file size.
nojf
Saves JSON without any formatting. Minimizes file size.
gzip
Saves JSON as a compressed gzip file. Minimizes file size.
nogzip
Saves JSON without any gzip compression (i.e., simple text file). Increases file size.
The default workfile save settings use the global options.
Foreign Source Save Options
These options only apply when saving your file to a format other than an EViews workfile. note that some of the options only apply to specific file types.
 
type=arg, t=arg
Optional type specification: (see table below).
Note that ODBC support is provided only in the EViews Enterprise Edition.
maptype=arg
Write selected maps as: numeric (“n”), character (“c”), both numeric and character (“b”).
nomapval
Do not write mapped values for series with attached value labels (the default is to write the mapped values if available).
noid
Do not write observation identifiers to foreign data files (by default, EViews will include a column with the date or observation identifier).
nonames
Do not write variable names (only application to file formats that support writing raw data without variable names).  Only available in EViews 12 and later.  EViews 11 and older should use nonames as an argument after the output file name.
na=arg
String value to be used for NAs.
attr
Include object attributes (if the output type supports it). When specified, the first column will contain attribute names and each attribute value will be displayed after the name row.
Excel Save Options
 
mode=arg
Specify whether to create a new file, overwrite an existing file, or update an existing file. arg may be “create” (create new file only; error on attempt to overwrite) or “update” (update an existing file, only overwriting the area specified by the range= table_description).
If the “mode=” option is not used, EViews will create a new file, unless the file already exists in which case it will overwrite it.
Note that the “mode=update” option is only available for Excel in 1) Excel versions through 2003, if Excel is installed, and 2) Excel 2007 (xml). Note: Excel does not need to be installed for Excel 2007 writing.
Excel 2007 Save Options
 
mode=arg
Specify whether to create a new file, overwrite an existing file, or update an existing file. arg may be “create” (create new file only; error on attempt to overwrite) or “update” (update an existing file, only overwriting the area specified by the range= table_description).
If the “mode=” option is not used, EViews will create a new file, unless the file already exists in which case it will overwrite it.
Note that the “mode=update” option is only available for Excel in 1) Excel versions through 2003, if Excel is installed, and 2) Excel 2007 (xml). Note: Excel does not need to be installed for Excel 2007 writing.
cellfmt=arg
Specify whether to use EViews, pre-existing, or remove cell formatting (colors, font, number formatting when possible, column widths and row heights) for the written range.
arg may be “eviews” (replace current formatting in the file with the same cell formatting in EViews), “preserve” (leave current cell formatting already in the Excel file), or “clear” (remove current formatting and do not replace).
strlen=arg
(default = 256)
Specify the maximum the number of characters written for cells containing text. Strings in cells which are longer the max, will be truncated.
The following table summaries the various formats along with the corresponding “type=” keywords:
 
 
Type Keywords
Supports Attributes
Access
“access”
 
Aremos-TSD
“a”, “aremos”, “tsd”
 
Binary
“binary”
 
dBASE
“dbase”
 
Excel (through 2003)
“excel”
Yes
Excel 2007 (xml)
“excelxml”
Yes
EViews Workfile
---
 
Gauss Dataset
“gauss”
 
GiveWin/PcGive
“g”, “give”
 
JSON
“json”
 
JSON (legacy output generated by EViews prior to EViews 12)
“jsonlegacy”
 
EViews workfile (WF1)
“wf1”
 
EViews workfile (WF2)
“wf2”
 
Lotus 1-2-3
“lotus”
 
ODBC Dsn File
“dsn”
 
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 (Version 7 Format)
“stata”
 
Tableau Data Extract
tde
 
Text / ASCII
“text”
Yes
TSP Portable
“t”, “tsp”
 
Note that if you wish to save your Excel 2007 XML file with macros enabled, you should specify the explicit filename extension “.XLSM”.
Foreign Data Descriptions
When saving to a foreign data format the base specification consists of a basic specification of source_description and table_description which specify the exact details of the format.
The command for saving as foreign data formats is
wfsave(options) source_description [table_description] [@keep keep_list] [@drop drop_list] [@keepmap keepmap_list] [@dropmap dropmap_list] [@smpl smpl_spec]
where the syntax of the table_description and variables_description differs slightly depending on the type of file.
@keep, @drop, @keepmap, @dropmap, and @smpl arguments may be used to control what objects and observations to write.
The nonames keyword may be used to suppress the writing of variable names in file formats that support writing raw data without variable names.
Note that saving as a foreign data file, with the exception of JSON, will save the current workfile page only.
The JSON type will save all series objects from all pages of the current working, ignoring any @keep, @drop, and @smpl arguments.
Excel Files
The base syntax for writing Excel files is:
wfsave(options) source_description [table_description]
where source_description is the path and name of the Excel file to be saved, and where the following table_description elements may be employed:
“range = arg”, where arg is a range of cells to read from the Excel workbook, following the standard Excel format [worksheet!][topleft_cell[:bottomright_cell]].
If the worksheet name contains spaces, it should be placed in single quotes. If the worksheet name is omitted, the cell range is assumed to refer to the currently active sheet. If only a top left cell is provided, a bottom right cell will be chosen automatically to cover the range of non-empty cells adjacent to the specified top left cell. If only a sheet name is provided, the first set of non-empty cells in the top left corner of the chosen worksheet will be selected automatically. As an alternative to specifying an explicit range, a name which has been defined inside the excel workbook to refer to a range or cell may be used to specify the cells to read.
“byrow”, transpose the incoming data. This option allows you to read files where the series are contained in rows (one row per series) rather than columns.
Examples
Text and Binary and Other Files
The base syntax for saving other files is:
wfsave(options) source_description
where source_description is the path and name of the file to be saved.
Examples
EViews Workfile Examples
wfsave new_wf
saves the current EViews workfile as “New_wf.WF1” in the default directory.
wfsave "c:\documents and settings\my data\consump"
saves the current workfile as “Consump.WF1” in the specified path.
wfsave macro @keep gdp unemp
saves the two series GDP and UNEMP in a separate workfile, “macro.WF1” in the default directory.
wfsave macro @dropmap gdp*
saves all of the series in the current workfile, other than those that match the name pattern “gdp*” in a workfile, “macro.WF1” in the default directory.
The command:
wfsave "<mydropboxdrive>"\folder\nipa.wf1"
will save the file to the cloud location MYDROPBOXDRIVE.
Foreign Data Examples
wfsave(type=excelxml, mode=update) macro.xlsx
saves the current workfile page as a modern Excel “.XLSX” file.
wfsave(type=excelxml, mode=update) macro.xlsx range="Sheet2!a1" byrow @keep gdp unemp
will save the two series GDP and UNEMP into the existing Excel file “macro.XLSX”, specifying that the series should be written by row, starting in cell A1 on sheet Sheet2.
To save the latter file in a macro-enabled Excel 2007 file, you should specify the explicit filename extension “.XLSM”,
wfsave(type=excelxml, mode=update) macro.xlsm range="Sheet2!a1" byrow @keep gdp unemp
Alternately,
wfsave(type=excelxml, noid) macro.xlsx range="Sheet2!a1"
will save the current workfile page as the Excel file “macro.XLSX” but will not include a column of dates.
If you wish to save a column of dates in a specific date format, you can do so by first creating an alpha series in the workfile with the specified format, then saving the file with the “noid” option including that alpha series:
alpha mydates = @datestr(@date, "YYYY-MM-DD")
wfsave(type=excelxml, noid) macro.xlsm range="Sheet2!a1" @keep mydates gdp unemp
will save the series GDP and UNEMP into the Excel file “macro.XLSM” along with a date series with the format “YYYY-MM-DD”.
Cross-references
See “Workfile Basics” for a discussion of workfiles.
See also pagesave, wfopen, and pageload.