help save9 (version 1.2, 18-Oct-2011)


save9 - Save dataset in Stata-9 format regardless of whether Stata 9, 10, 11 or 12 is being run.


save9 filename [, nolabel replace all ]


save9 saves, in the Stata-9 format, the dataset in memory to disk regardless of whether Stata 9, 10, 11 or 12 is being run. If filename is specified without an extension, .dta is assumed. If filename contains embedded spaces, remember to enclose it in double quotes " ". save9 can be useful in situations where authors who are running different editions of Stata may wish to share the same .do scripts and the same datasets.

Note that any attempt to exit Stata after the save9 command might result in the warning no; data in memory would be lost if Stata 10, 11 or 12 last saved the data in the Stata-9 format. This is a default behaviour of Stata insofar as it expects the data to be saved in the lastest format before exiting. This default behaviour can be overcome by issuing the clear command before issuing the exit command.

save9 will also work in Stata-8 but it will save the dataset in the Stata-8 format. Stata-8 datasets have a limit of 244 characters for their values labels, Stata-9 datasets have a limit of 32,000 characters but in all other ways the Stata-8 and Stata-9 dataset formats are equivalent. save9 will not work in Stata-7 or earlier.

save9 works by using the creturn code c(stata_version) to determine which version of Stata is being run. It then uses this to decide if to include the undocumented oldformat option when calling the save command.


nolabel prevents value labels in the dataset from being saved.

replace permits overwriting of an existing dataset.

all saves e(sample) with the dataset; programmer's option.


Marco G. Ercolani


. save9 MyData, replace

. save9 "My Data"

. save9 "My Data.dta"

. save9 "My Data.dta", nolabel replace

Also see