help use10
-------------------------------------------------------------------------------

Title

use10 -- Use Stata 10 format dataset in Stata 9

Syntax

Load Stata-10 format dataset in Stata 9

use10 filename [, clear nolabel saving(filename) replace]

Load subset of Stata-10 format dataset

use10 [varlist] [if] [in] using filename [, clear nolabel]

Description

use10 loads into memory a dataset previously saved by Stata 10 or compatible software. If filename is specified without an extension, .dta is assumed. If your filename contains embedded spaces, remember to enclose it in double quotes.

In the second syntax for use10, a subset of the data may be read.

use10 is written in Mata and requires Stata 9. Datasets written with save in Stata 9 can be loaded in Stata 8 with standard use command.

use10 will automatically call standard Stata's use command if it determines that the file is not in Stata 10 format. Hence it is safe to always open data with use10 rather than use.

Stata 10 files may contain more formatting then Stata 9 format can accomodate. This applies to date and time formats only. It does not apply to data types. This program will automatically replace formats that are potentially incompatible with Stata 9 with a default format (in this version it is %15.0g). Although some date and time formats can be accomodated in Stata 9 without a loss, the exact rules for validation were not known at the time this program was written. Replacement of potentially incompatible formats with a default format is also a preferred strategy of Stata 10 when saving data in Stata 9 format with saveold. use10 lists original data types and formats for each variable. Skilled users can change file use10reformat.ado to accomodate any changes in formats they demand. Corresponding instructions are located in the use10reformat.ado file. Deleting this file is not recommended (but it is possible: use10 will still work).

Performance use10 loads ~420MB file slightly slower (<10%) than it takes Stata to saveold and use the same file (48.75 seconds vs 32.17+12.34 seconds). Conversion is always done for the whole dataset and only after that particular data is selected based on the specified if- and in-restrictions and variables list.

Compatibility use10 is tested in 32-bit Stata for Windows. It is written in Mata and should be compatible with all OSes that Stata runs on, supports HILO and LOHI Stata datasets and should also be compatible with large datasets (>2GB, from Stata 64-bit).

Error messages use10 will attempt to detect if the file is ill-formed and issue standard Stata error messages in such a case, but (as it is the case with Stata's use) loading corrupt datasets is unlikely to succeed. Non-standard messages of use10 include:

"Warning: file does not conform to Stata-10 specification (file signature 114)"

This message is issued when file signature is different from what is expected according to Stata 10 file format. This is just a warning, it is most often a signal that the file is originating from an earlier Stata - the program will attempt to load the dataset with standard use command and all further messages (if any) are coming from Stata itself.

"Warning! NNN variable(s) have different format after conversion"

This message is a signal that some incompatible formats were detected in the dataset and the user must verify (and if necessary manually redefine formats for some variables). It is the responsibility of use10reformat.ado to find an appropriate new format for an incompatible format and inform the user of any such replacement. By default, all variables are listed with their respective data storage types, and formats. If the format is changed, this is indicated by a red star preceding variable name and the new format displayed in brackets after the original format.

Options

clear specifies that it is okay to replace the data in memory, even though the current data have not been saved to disk.

nolabel prevents value labels in the saved data from being loaded. It is unlikely that you will ever want to specify this option.

saving(filename) specifies where the converted file should be saved. If this op > tion is not specified - a temporary location is used.

replace (makes sense only with option saving(filename) allows the file specifie > d in saving(filename) to be replaced.

Some technical details use10 is an rclass command use10 uses global variable use10_newformat during it's work use10 sets r(fn) to the original (Stata-10 format) dataset unless the option saving is specified. In that case r(fn) will be set to the name specified in saving When option saving(filename) is specified with an if- or in-qualifiers (or both) the dataset is converted in full, saved to the specified file, and a portion of it is subsequently loaded. If option replace was specified, file with the name specified in option saving(filename) is deleted regardless of whether use10 succeedes or not.

Author

use10 was written by Sergiy Radyakin, sradyakin(at)worldbank.org

Examples

The following example will copy a Stata 10 format demo dataset from Stata Corp > website and load it in Stata 9.

. tempfile auto10 . copy http://www.stata-press.com/data/r10/auto.dta `auto10' . use10 `auto10' ------------------------------------------------------------------------------- Variable name Type Format[New Format] ------------------------------------------------------------------------------- make str18 %-18s price int %8.0gc mpg int %8.0g rep78 int %8.0g headroom float %6.1f trunk int %8.0g weight int %8.0gc length int %8.0g turn int %8.0g displacement int %8.0g gear_ratio float %6.2f foreign byte %8.0g ------------------------------------------------------------------------------- (1978 Automobile Data)

. use10 make rep78 foreign using `auto10', clear

For local files use command use10 in the same fashion you use use, e.g.:

. use10 var1 var2 using dataset10.dta if (var1>0) & (var2<.), clear

Also see

Manual: [D] use

Online: [D] use, [D] sysuse, [D] webuse