*! version 1.0 2012-12-07
help excelsave (vs1.0: 2012-12-07)

Title

excelsave -- Exporting Stata datasets to Excel with respect to matching criterion within selected
folder (and also possibly within separately matched subfolders).

Syntax

excelsave [if] [in] [, vars(string) folder(string) match(string) subs(string) xls *]

Description

excelsave
is a program that helps to export (sets of) Stata datasets in a quite generally applicable fashion -
through matched datasetnames from a stated in-directory - and also, if selected, from all separately matched subdirectories.
If selected, only a selected list of variables will be exported and, similarly, specific if- and -in-conditions could also be used.
The simplest syntax is purely based on defaults. All options are optional.

Note that this serves as a full wrapper for -export excel- and hence all options available with that command may also be used
- and will then be passed on - here as well.

Options

vars(string) List of variables to be exported from each file. The default set is all variables ('*').

folder(string) Defines the directory from within where to look for files.
The default directory is the current working directory (cwd; '.').

match(string) Defines the matching criterion used in order to select files
from the selected directory folder, and - if selected - matched (by subs) subdirectories.
The default is all files in the directory/directories ('*').

subs(string) Defines whether, or not, matched files (by match) in corresponding
separately matched subdirectories (recursively; based on here defined matching criterion) also should
be affected. (Matching must be present at all levels.)

xls Defines that the output Excel-format should be .xls; the default format is .xlsx

* List of all stated (valid) options to -export excel- that will be passed on to the (internal) call to that command.

Examples

1. Export all files in current working directory.

. excelsave

2. Export all files with prefix name located in cwd-subdirectory data.

. excelsave , folder(".\data") match("name*")

3. Export all files with prefix name located in cwd-subdirectory data - and also from
within any available subdirectories.

. excelsave , folder(".\data") match("name*") subs("*")

4. Export all files located in cwd-subdirectory data - and also from any subdirectories with prefix 2011.
Restrict the exporting to variables prefixed by cid1*.

. excelsave , vars("cid1*") folder(".\data") match("*") subs("2011*")

5. Same as Example 4, but with matching based on prefix name and output format set to .xls. Moreover, the actual exporting
layout will also be affected by passed on -export excel- options firstrow(var) and replace.

. excelsave , vars("cid1*") folder(".\data") match("name*") subs("2011*") xls firstrow(var) replace

Requires

Stata 12.
Moreover, the command depends on the Stata 12 command export excel.

Author

Lars Ängquist

Lars.Henrik.Angquist@regionh.dk

lars@angquist.se

Related commands (downloadable on SSC)

renfiles - renaming set of matched files

rmfiles - removing set of matched files

mvfiles - moving set of matched files

use10save9 - save Stata 10/11 files as Stata 9 counterparts (also from within Stata 9)

Also see

Help: [help pages on] export excel, extended_fcn, dir, copy, erase, mkdir.