help for appendall

Appending All Eligible Files in the Specified Folder

appendall appending all eligible files (such as Stata, Excel, CSV or Text) in the specified folder.

Syntax

appendall using folder [ , save(filepath) subdirectory
attribute(string) order(string) pattern(string) regex type(filetype)
importopt(options) complete do(program) progress open append_options ]

Options

save(filepath) is optional, defines name and path about new appended file. The default file name is "AppendALLFile".

subdirectory is optional, also appends files in the subdirectory of folder.

attribute(string) is optional, specifies file attributes such as attribute(-H-S). The default is none.

order(string) is optional, specifies the ordering method for appended files. The default is to order by files' names (i.e. order(ON)).

pattern(string) is optional, sets criteria of name to filter appended files.

regex is optional, treats the pattern(string) as a regular expression. The default as a general match.

type(filetype) is optional, specifies new saved file format (one of dta, csv, txt, xls, xlsx or excel). The default is type(dta).

importopt(options) are optional, are any options available for import if type(filetype) is not "dta".

complete is optional, keep complete path (if option subdirectory is set) and type (i.e. '.dta') of files in variable "Filename".

do(program) is optional, is a pre-processing inbuilt program (or a do file) with standard Stata syntax,
such as do(myprogram [args], [options]) or do(do filename [args]).

progress is optional, displays the appending progress of files.

open is optional, loads appended file in save(filepath).

append_options are optional, are any options available for append.

*** Important Notes:

1. If option save(filepath) only have a file name without a path, the default path is the folder in using;

2. If The size of appended excel files are larger than 40MB, you had better execute program "set excelxlsxlargefile on" before using command appendall.

Examples

. appendall using "E:\New folder"

. appendall using "E:\New folder", save("E:\Researchdata\result")

. appendall using "E:\New folder", subdirectory

. appendall using "E:\New folder", save("result") subdirectory

. appendall using "E:\New folder", subdirectory complete

. appendall using "E:\New folder", attribute(-H-S)

. appendall using "E:\New folder", order(OD)

. appendall using "E:\New folder", pattern(2020)

. appendall using "E:\New folder", pattern("^2") regex

. appendall using "E:\New folder", save("result") subdirectory open

. appendall using "E:\New folder", save("result") subdirectory force

. appendall using "E:\New folder", save("result") subdirectory attribute(-H-S) pattern("^2") regex

. appendall using "E:\New folder", save("result") type(csv)

. appendall using "E:\New folder", save("result") type(txt) importopt(delim(tab) encoding(utf-8))

. appendall using "E:\New folder", save("result") type(xls) subdirectory

. appendall using "E:\New folder", save("result") type(xlsx) importopt(firstrow)

. appendall using "E:\New folder", save("result") type(excel) importopt(firstrow case(preserve))

. appendall using "E:\New folder", save("result") type(excel) importopt(firstrow) keep(var1 var3 var6)

. appendall using "E:\New folder", save("result") do(mydo) //mydo is a user-defined program

. appendall using "E:\New folder", save("result") progress

Authors

Dejin Xie, School of Economics and Management, Nanchang University, China.

E-mail: xiedejin@ncu.edu.cn.

Also see

Help: append, merge, joinby, cross.