*! version 1.2 2011-12-22
help use10save9 (vs1.1: 2011-10-25) (vs1.2: 2011-12-22)

Title

use10save9 -- Saving matched files in Stata 9 format - either as new files in automatically
created directory or through replacing previous Stata 10/11 files.

Syntax

use10save9 [, folder(string) match(string) subs(string) prefix(string) suffix(string) replace newstx]

Description

use10save9
is a program that helps out with opening Stata 10/11 files from within Stata 9 and then saving them in Stata 9 format
(using use10 and save9). May be applied to a quite generally defined set of Stata datasets within a
defined folder and, if selected, also with respect to all matched corresponding subfolders.
The simplest syntax is purely based on defaults. All options are optional.

An alternative, secondary, usage might be to simply use the function as an extension to save9 (Ercolani, 2011)
in order to save matched sets of datasets in Stata 9 format while being in Stata 10/11/12.

Options

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 matched
subdirectories (recursively; based on here defined matching criterion) also should be affected.
(Matching must be present at all levels.)

prefix(string) Defines a prefix string to put in front of all new files corresponding
to matched cases.

suffix(string) Defines a suffix string to put at the end of all new files corresponding
to matched cases.

replace An indicator for whether, or not, the matched files should be saved as new files in subdirectory
'stata9'(which is then - if not existing - automatically created) or rather simply be saved (with 'replace') in
folder or relevant subdirectory (potentially overwriting, if no prefix/suffix assigned, the old versions).

newstx An indicator for whether, or not, Stata 11 syntax (as compared to Stata 9 syntax) should be assumed
with respect to extended macro functions. If not stated, matching will not be case-sensitive and hence all matching
strings string (with respect to match and subs) should be entered in lower case.

Examples

1. Save all (Stata dataset) files in current working directory in Stata 9 format in subdirectory 'stata9'.

. use10save9

2. Save all files with prefix name located in cwd-subdirectory data in Stata 9 format in subdirectory 'stata9'.

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

3. Same as Example 2, but in this case all matched files in all subdirectories to folder data are also to be affected.

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

4. Same as Example 3, but in this case all matched files in folder data should simply be saved replacing (overwriting) the original ones.

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

5. Same as Example 4, but in this case all new files will have prefix 's9_' added to filenames (for instance, to avoid overwriting).

. use10save9 , folder(".\data") match("name*") subs("*") prefix("s9_") replace

6. Similar to Example 5, but in this case using the new syntax, leading to case-sensitive matching. Hence, here one may use upper case matching-notation
and only files and directories exactly with prefixes Name and Subdir will be matched respectively.

. use10save9 , folder(".\data") match("Name*") subs("Subdir*") prefix("s9_") replace newstx

Requires

Stata 9; newer versions needed when option newstx is used.
Moreover, the command depends on the user written functions use10 (Radyakin, 2008) & save9 (Ercolani, 2011).

Author

Lars Ängquist

Lars.Henrik.Angquist@regionh.dk

lars@angquist.se

Acknowledgements

Testing assistance by Birgit Marie Nielsen (Thanks Birgit! / LÄ)

Related commands (downloadable on SSC)

mvfiles - moving set of matched files

renfiles - renaming set of matched files

rmfiles - removing set of matched files

excelsave - exporting set of matched files to Excel (.xls or .xlsx)

Also see

Help: [help pages on] use10 (user-written; SSC), save9 (user-written; SSC),

save, mkdir, varlist, extended_fcn, string functions.