Home  /  Resources & support  /  FAQs  /  Reading a Stata dataset with an older version of Stata

How can I save a Stata dataset so that it can be read by a previous version of Stata?

Title   Reading a Stata dataset with an older version of Stata
Author Shannon Driver and Derek Wagner, StataCorp

The format sometimes changes between releases to allow for new features. This format change can cause problems when two colleagues are working on a project and one of them has not upgraded to the latest release. For example, when a Stata 13 user tries to open a Stata 16 dataset from a colleague, they are presented with an error,

        . use auto.dta
        file auto.dta from a more recent version of Stata
        r(610);

There is, however, an easy solution to this problem. First, when we have to change Stata's dataset format, we always update the previous version of Stata to be able to read the format of the next version. Often this will be all you need. Simply make sure your Stata is up-to-date (type update), and you will be able to read a dataset from the next version of Stata even if the format is different.

If you receive data from a colleague with a newer version of Stata, ask them to use Stata's saveold command. See the links below.

To avoid errors, please make sure that you have installed the most recent update for your version of Stata.


Saving datasets in Stata 14, Stata 15, or Stata 16 so that they can be read by Stata 11, Stata 12, or Stata 13

Stata 16, 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.

The version(#) option was added in Stata 14, and it specifies which previous .dta file format is to be used. # may be 13, 12, or 11. The default is version(13), meaning Stata 13 format.

To save a dataset in Stata 14, Stata 15, or Stata 16 so that it can be used in Stata 13, use the saveold command.

        . saveold autoold, version(13)
        file autoold.dta saved

or

        . saveold autoold
        file autoold.dta saved

To save a dataset in Stata 14, Stata 15, or Stata 16 so that it can be used in Stata 12, use the saveold command with the version option.

        . saveold autoold, version(12)
        file autoold.dta saved

To save a dataset in Stata 14, Stata 15, or Stata 16 so that it can be used in Stata 11, use the saveold command with the version option.

        . saveold autoold, version(11)
        file autoold.dta saved

Saving datasets in Stata 13 so that they can be read by Stata 11 or Stata 12

To save a dataset in Stata 13 so that it can be used in Stata 11 or Stata 12, use the saveold command.

        . saveold autoold
        file autoold.dta saved

Saving datasets in Stata 12 so that they can be read by Stata 11

Stata 11 can read Stata 12 datasets, so you do not need to do anything special:

        . save auto
        file auto.dta saved

Saving datasets in Stata 12 so that they can be read by Stata 8, Stata 9, or Stata 10

To save a dataset in Stata 12 so that it can be used in any of Stata 8 through Stata 10, use the saveold command.

        . saveold autoold
        file autoold.dta saved

Saving datasets in Stata 10 or Stata 11 so that they can be read by Stata 8 or Stata 9

To save a dataset in Stata 10 or Stata 11 so that it can be used in Stata 8 or Stata 9, use the saveold command.

        . saveold autoold
        file autoold.dta saved

Saving datasets in Stata 9 so that they can be read by Stata 8

Stata 8 and Stata 9 datasets have the same format. Therefore, a dataset saved in Stata 9 can be used in Stata 8 with no problems or extra work.

The only issue related to this is that Stata 9 allows value labels to be up to 32,000 characters long. If Stata 8 tries to read a Stata 9 dataset with value labels that exceed the Stata 8 limit (244 for Stata/SE; 80 for Stata Intercooled), Stata 8 will ignore those labels and read the rest of the dataset.


Saving datasets in Stata 8 or Stata 9 so that they can be read by Stata 7

To save a dataset in Stata 8 or Stata 9 so that it can be used in Stata 7, use the saveold command.

        . saveold auto7
        file auto7.dta saved

Saving datasets in Stata 4 to Stata 7 so that they can be read by the previous version

To save a dataset in Stata 4, 5, 6, or 7 so that it can be read by the previous version, use the save command with the old option.

        . save auto6, old
        file auto6.dta saved

The old option in Stata 7 will not automatically truncate long variables or label names. You will need to rename the variables and labels.

Also, if any of your variables have value labels and the name of the value label is longer than 8 characters, you must either drop or rename those value labels.

        . label list
        origin:
                  0 Domestic
                  1 Foreign

        . label save origin using mylabel.do
        file mylabel.do saved

This command will produce a do-file called mylabel.do with the following commands:

        -------------------------------------------------mylabel.do
        label define origin 0 `"Domestic"', modify
        label define origin 1 `"Foreign"', modify
        -------------------------------------------------mylabel.do