import excel — Import and export Excel files 3
import excel auto first looks for auto.xls and then looks for auto.xlsx if auto.xls is not
found in the current directory.
The default file extension for export excel is .xls if a file extension is not specified.
Options for import excel
sheet("sheetname") imports the worksheet named sheetname in the workbook. The default is to
import the first worksheet.
cellrange(
start
:end
) specifies a range of cells within the worksheet to load. start and end
are specified using standard Excel cell notation, for example, A1, BC2000, and C23.
firstrow specifies that the first row of data in the Excel worksheet consists of variable names. This
option cannot be used with extvarlist. firstrow uses the first row of the cell range for variable
names if cellrange() is specified. import excel translates the names in the first row to valid
Stata variable names. The original names in the first row are stored unmodified as variable labels.
case(preserve | lower | upper) specifies the case of the variable names read when using the
firstrow option. The default is case(preserve), meaning to preserve the variable name case.
allstring forces import excel to import all Excel data as string data.
clear clears data in memory before loading data from the Excel workbook.
The following option is available with import excel but is not shown in the dialog box:
locale("locale") specifies the locale used by the workbook. You might need this option when
working with extended ASCII character sets.
Options for export excel
Main
sheet("sheetname") saves to the worksheet named sheetname. If there is no worksheet named
sheetname in the workbook, a new sheet named sheetname is created. If this option is not
specified, the first worksheet of the workbook is used.
cell(start) specifies the start (upper-left) cell in the Excel worksheet to begin saving to. By default,
export excel saves starting in the first row and first column of the worksheet.
sheetmodify exports data to the worksheet without changing the cells outside the exported range.
sheetmodify cannot be combined with sheetreplace or replace.
sheetreplace clears the worksheet before the data are exported to it. sheetreplace cannot be
combined with sheetmodify or replace.
firstrow(variables | varlabels) specifies that the variable names or the variable labels be saved
in the first row in the Excel worksheet. The variable name is used if there is no variable label for
a given variable.
nolabel exports the underlying numeric values instead of the value labels.
replace overwrites an existing Excel workbook. replace cannot be combined with sheetmodify
or sheetreplace.