help mi convert dialog: mi
-------------------------------------------------------------------------------
Title
[MI] mi convert -- Change style of mi data
Syntax
mi convert wide [, options ]
mi convert mlong [, options ]
mi convert flong [, options ]
mi convert flongsep name [, options ]
option description
-------------------------------------------------------
clear okay to convert if data not saved
noupdate see [MI] noupdate option
-------------------------------------------------------
Menu
Statistics > Multiple imputation
Description
mi convert converts mi data from one style to another.
Options
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
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 get an error, you will have to either live with the flongsep style or
increase the amount of memory allocated to Stata; see [D] memory. To
increase the amount of memory, type
. clear all
. set memory 50m <-- (for instance)
. use your_flongsep_data
. mi convert mlong
Our use of 50m is just an example. You need to choose a number large
enough to hold the data but not so large as to cause your computer to use
virtual memory, because then everything runs slowly.
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 number reported as "data + overhead", which we will call 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. So we would try
set memory 49m.
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.
Also see
Manual: [MI] mi convert
Help: [MI] intro; [MI] styles