Stata 15 help for mi_convert

[MI] mi convert -- Change style of mi data


mi convert wide [, options]

mi convert mlong [, options]

mi convert flong [, options]

mi convert flongsep name [, options]

options Description ------------------------------------------------------------------------- clear okay to convert if data not saved

noupdate see [MI] noupdate option -------------------------------------------------------------------------


Statistics > Multiple imputation


mi convert converts mi data from one style to another.


clear specifies that it is okay to convert the data even if the data have not been saved to disk since they were last changed.

noupdate in some cases suppresses the automatic mi update this command might perform; see [MI] noupdate option.


Remarks are presented under the following headings:

Using mi convert as a convenience tool Converting from flongsep Converting to flongsep

Using mi convert as a convenience tool

Some tasks are easier in one style than another. mi convert allows you to switch to the more convenient style. It would not be unreasonable for a snippet of a session to read

. mi convert wide

. drop if sex=="male"

. mi convert mlong, clear

. replace age2 = age^2

This user is obviously exploiting his or her knowledge of [MI] styles. The official way to do the above would be

. drop if sex=="male"

. mi update

. mi passive: replace age2 = age^2

It does not matter which approach you choose.

Converting from flongsep

If you have flongsep data, it is worth finding out whether you can convert it to one of the other styles. The other styles are more convenient than flongsep, and mi commands run faster on them. With your flongsep data in memory, type

. mi convert mlong

The result will be either success or an insufficient-memory error.

If you wish, you can make a crude guess as to how much memory is required as follows:

1. Use your flongsep data. Type mi describe. Write down M, the number of imputations, and write down the number of complete observations, which we will call N, and the number of incomplete observations, which we will call n.

2. With your flongsep data still in memory, type memory. Write down the sum of the numbers reported as "data" and "overhead" under the "used" column. We will call this sum S for size.

3. Calculate T = S + M*S*(n/N). T is an approximation of the memory your mi data would consume in the mlong style. To that, we need to add a bit to account for extra memory used by Stata commands and for variables or observations you might want to add. How much to add is always debatable. For large datasets, add 10% or 5 MB, whichever is smaller.

For instance, you might have

M = 30 N = 10,000 n = 1,500 S = 8,040,000 = 8 MB

and thus we would calculate T = 8 + 30*8*(1500/10000) = 44 MB, to which we would add another 4 or 5 MB, to obtain 48 or 49 MB.

Converting to flongsep

Note that mi convert's syntax for converting to flongsep is

mi convert flongsep name

You must specify a name, and that name will become the basis for the names of the datasets that comprise the collection of flongsep data. Data for m=0 will be stored in name.dta; data for m=1, in _1_name.dta; data for m=2, in _2_name.dta; and so on. The files will be stored in the current directory; see the pwd command in [D] cd.

If you are going to use flongsep data, see Advice for using flongsep in [MI] styles. Also see [MI] mi copy and [MI] mi erase.

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