### Stata FAQ How can I convert a Stata data file to an Mplus data file?

We have created a program called stata2mplus that you can use to convert your Stata data into a data file (a .dat file) and Mplus program (.inp file) that you can use in Mplus. You can download stata2mplus by typing findit stata2mplus (see How can I use the findit command to search for programs and get additional help? for more information about using findit).

Say we wanted to convert the a file called c:\data\hsb2.dta to an Mplus data file. After installing stata2mplus, you would type this.
stata2mplus using c:\data\hsb2
This then creates c:\data\hsb2.dat and c:\data\hsb2.inp .  Then you would start Mplus and click File then Open and choose c:\data\hsb2.inp and then you can run that program to get a basic analysis (with descriptive statistics) to check to see that the file was converted properly.  Then, you can modify the program to use the variables you wish and start to build your Mplus model.

Say you wish to convert just the variables read write math science then you can do this.  Note we also used the replace option to indicate we wanted to overwrite the existing .dat and .inp files.
stata2mplus read write math science using c:\data\hsb2 , replace
Or if you wanted to convert all of the variables but put into the usevariables statement in Mplus that you wish to use just read write math science then you can do this.
stata2mplus using c:\data\hsb2 , use( read write math science) replace
By default, missing values are converted to -9999.  If you want to use a different value (say -1234) for missing, you can do this.  Missing values must be integers.
stata2mplus using c:\data\hsb2 , use( read write math science) missing(-1234) replace

The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.