use13 facilitates data exchange between users who have not updated to the new version of Stata and other users, who have Stata 13 already. Stata is backwards compatible and all new versions read files produced with any previous version. However older versions of Stata do not understand newer formats. A proper way of sending data to older version is to use Stata's command saveold, but it is only an option for the data producer posessing Stata 13 already.
Here is what the users need to know about the assumptions and limitations of use13:
To install use13 type literally the following in Stata's command prompt:
findit use13
Then click on the link for -use13- in the Stata's viewer and click the -install- link.
The above installation instructions are sufficient in most cases when Stata is permitted to access the Internet. To transfer files to a computer not connected or not permitted to connect to the Internet, manually copy the files from the distribution package.
To install use10 proceed to use10 page for instructions.
To import a file type the following command in Stata's command line:
use13 filename
For example:
use13 C:\Data13\auto.dta
Filenames with spaces or commas must be enclosed in quotes:
use13 "C:\My Data 13\auto.dta"
If your data in memory is modified, and you want to proceed anyway, specify option clear:
use13 "C:\My Data 13\auto.dta", clear
Web data is also accessible with this command:
use13 "http://www.stata-press.com/data/r13/auto.dta"Datasets accompanying Stata releases are available on Stata Press website.
To get information about the program, type:
mata use13_about()
Stata's built-in file manipulation commands are not affected by use13, and you will continue getting error 610 on attempt to use them with Stata 13 files. More details in the next section below.
StataCorp does not allow modifications to their Stata's built-in commands by the users. It is technically possible to let the user supply a custom procedure to handle conversion of the unknown types of files, but this conversion process:
Hence data conversion is usually a separate step before data processing.
In most cases converting the dataset manually with use13 and storing the converted file to process it later is the preferred mode of operation. However in some systems the files may be generated automatically and for example downloaded from a remote system for processing.
Specifically, this means that you should not expect that after installing use13 you will be able to e.g. load the Stata 13 data in e.g. Stata 12 with the same command, such as:
use "file13.dta"Stata still stop with an error 610 "file not Stata format" and this is a normal and unavoidable behavior. Instead you must write:
use13 "file13.dta"
Similarly, but perhaps not as obviously, the other Stata's commands (append, merge, etc) will not know anything about the new format, and installation of use13 will not change it. The code of the append command will not be affected in any way, but instead, as described above, you will need to do a two-step process of converting the file first, then executing the actual command. For example, to append a Stata 13 file:
tempfile tmp preserve use13 "C:\My Data 13\auto.dta", clear save "`tmp'" restore append using "`tmp'"
We can even envelop this code into a new program of its own:
program define append13 syntax using filename, [*] tempfile tmp preserve use13 "`0'", clear save "`tmp'" restore append using "`tmp'", `options' end
This primitive command does not support the file list for appending, which was added in Stata 11. There is no problem to do that too. Append is an .ado file, and viewsource append.ado would reveal it's implementation. Each of the two calls to _append should be prepended with the conversion code, similar to illustrated above. If you care about efficiency, more efficient ways to do it exist, but there is no point to pursue them as use13 is seen only to feel in the temporary capability gap.
It is not recommended to replace any commands supplied by StataCorp with any custom modifications, unless you really, really, really know what you are doing. Hence the above command is named append13 and not append, since then it might affect the performance of other parts of the system, which utilize append.
To merge current dataset with a Stata 13 dataset:
tempfile tmp preserve use13 "C:\My Data 13\auto.dta", clear save "`tmp'" restore merge make using `"`tmp'"'
You will need to sort data just as you normally merge the datasets that Stata understands natively. Note that use13 preserves not only the order of observations of the original dataset, but also the sort order of the original dataset! You do not need to re-sort the converted file before the merge if it was already sorted.
The only exception to this is when the sort key included a strL variable or a strF variable that can't be accommodated in Stata 12 and earlier (longer than 244 characters). Then sorting key will change. But you would need to re-sort the data anyway. The order of observations in the converted dataset never deviates from the original.
For all other commands the principle is the same, if a command requires a dataset name on disk as a parameter, convert that file from Stata 13 format before running this command. Use tempfiles whenever possible if you are doing it on-the-fly (without storing the converted dataset).
Despite every effort was made to make use13 robust and error-free, bugs are still possible, just like in any other program. If you are getting an error while executing the use13 command, consider the following:
which use13 mata use13_about()
<stata_dta><header><release>117</release><byteorder>If your file starts with a different content, use13 will not read it. You can use Stata's command -type- to check the content in the header of the file:
type "filename.dta"
use13 was written by Sergiy Radyakin.
To contact the author send email to: sradyakin/at/worldbank.org.
In case you are experiencing a problem converting a dataset, refer to the following troubleshooting reference first, before requesting assistance.
I am grateful to
for recommending use13 to their users.Chuck Huber (StataCorp) also recommended use13 to directly read the data from Stata 13 files in the Stata Blog.