Stata 15 help for save

[D] save -- Save Stata dataset

Syntax

Save data in memory to file

save [filename] [, save_options]

Save data in memory to file in Stata 13, 12, or 11 format

saveold filename [, saveold_options]

save_options Description ------------------------------------------------------------------------- nolabel omit value labels from the saved dataset replace overwrite existing dataset all save e(sample) with the dataset; programmer's option orphans save all value labels emptyok save dataset even if zero observations and zero variables -------------------------------------------------------------------------

saveold_options Description ------------------------------------------------------------------------- version(#) specify version 11<=#<=14; default is version(13), meaning Stata 13 format nolabel omit value labels from the saved dataset replace overwrite existing dataset all save e(sample) with the dataset; programmer's option -------------------------------------------------------------------------

Menu

File > Save as...

Description

save stores the dataset currently in memory on disk under the name filename. If filename is not specified, the name under which the data were last known to Stata (c(filename)) is used. If filename is specified without an extension, .dta is used. If your filename contains embedded spaces, remember to enclose it in double quotes.

Stata 15 and Stata 14 have the same dataset format so long as the dataset has 32,767 variables or less. Stata/MP 15 supports more than 32,767 variables and thus has a slightly different dataset format when there are that many variables. If you are using Stata 15 and want to save a file so that it may be read by someone using Stata 14, simply use the save command; Stata 14 will be able to read it so long as it does not have more than 32,767 variables. Stata 14 supports at most 32,767 variables

saveold saves the dataset currently in memory on disk under the name filename in previous .dta formats, namely, those for Stata 13, 12, or 11. If you are using Stata 15 and want to save a file so that it may be read by someone using an older version of Stata, use the saveold command.

Options for save

nolabel omits value labels from the saved dataset. The associations between variables and value-label names, however, are saved along with the dataset label and the variable labels.

replace permits save to overwrite an existing dataset.

all is for use by programmers. If specified, e(sample) will be saved with the dataset. You could run a regression; save mydata, all; drop _all; use mydata; and predict yhat if e(sample).

orphans saves all value labels, including those not attached to any variable.

emptyok is a programmer's option. It specifies that the dataset be saved, even if it contains zero observations and zero variables. If emptyok is not specified and the dataset is empty, save responds with the message "no variables defined".

Options for saveold

version(#) specifies which previous .dta file format is to be used. # may be 14, 13, 12, or 11. The default is version(13), meaning Stata 13 format. To save datasets in the modern, Stata 15 format, use the save command, not saveold. Stata 15 and Stata 14 share the same format, so you do not have to use saveold to save a Stata 14 dataset; simply use save.

nolabel omits value labels from the saved dataset. The associations between variables and value-label names, however, are saved along with the dataset label and the variable labels.

replace permits saveold to overwrite an existing dataset.

all is for use by programmers. If specified, e(sample) will be saved with the dataset. You could run a regression; save mydata, all; drop _all; use mydata; and predict yhat if e(sample).

Examples

Setup . input number odd even

number odd even 1. 1 1 2 2. 2 3 4 3. 3 5 6 4. 4 7 8 5. end

Save data in memory to file . save myevenodd

Add another observation . input

number odd even 5. 5 9 10 6. end

Resave myevenodd after additional observation has been added . save myevenodd, replace

Equivalent to above command . save, replace

Save data under name myevenodd2 in Stata 13 format . saveold myevenodd2

Save data under name myevenodd3 in Stata 12 format . saveold myevenodd3, version(12)


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index