Reading Mplus Datasets

I have described elsewhere which type of data files Mplus can read and how they are created.

To read the data, use the DATA command.

Free format

Data in free format are most easy to use, as you don't have to go into the trouble of defining the exact position of variables. All you have to do is to indicate the file where the data are to be found. Of course, in the variables section you will have to name your variables (which is also the case with fixed format data).

DATA:
       FILE IS "C:\directory\subdirectory\filename.csv";

Note that the suffix "csv" is not needed to indicate a csv file to Mplus. It is, however, useful in order for yourself to see at a glance which type of file you are dealing with.

Fixed format

To follow.

Multiply imputed data

With multiply imputed data, Mplus expects several data files, corresponding to the number of imputed data sets created. Treatment of these data files is slightly different from normal procedure:

  • The DATA statement in this case does not refer to a data set, but rather to a file that contains the names of the different data sets; an additional keyword informs Mplus that it has to deal with imputed data.
  • The file referred to on the DATA statement is an ASCII file that lists the names of the data files, with each file name starting on a new line.

This might look like this:

DATA:
       FILE IS "C:\directory\subdirectory\mifilenames.txt";
       TYPE = IMPUTATION;

The file "mifilenames.txt" might look like this:

midata1.csv
midata2.csv
midata3.csv

and so on, according to the number of files you have created. This set-up assumes that the imputed data sets are in the same directory as "mifilenames.txt". You might probably also indicate paths leading to different directories.

© W. Ludwig-Mayerhofer, Mplus Guide | Last update: 08 Mar 2010