Stats Work

Get [M]oving with Mplus – part 3: Get Your Data On

Unlike other programs like SPSS or Stata, data entry is done externally with Mplus. In other words, you will need to use another spreadsheet or stats program to transfer your data into Mplus. Typically I use SPSS because 1) it’s how I learned it and 2) it’s also the program I am most familiar with. But this can also be done, to the extent of my knowledge, from Stata and SAS (and probably others as well). In any case, I will review how to do it from SPSS (and others in the future!).

From SPSS:

  1. Acquire and open SPSS dataset you want to analyze in Mplus
  2. Transform missing data into a numeric indicator
  • Select Transform in the menu bar
  • Scroll down to and select Recode into same variable 
  • Select all your variables, move them into the numeric variables box
  • Select Old and New Values…
  • In the Old Value box select System-missing
  • In the New value box enter -999 (or any missing value identifier you prefer)
  • Press Add
  • Select Continue and then OK
  1. Double check format of columns (i.e., width, decimals, alignment)
  • Width = 8
  • Decimals = 2
  • Align = right
  • Short variable names (shoot for 5 characters or less, but definitely no more than 8)
  1. Save as Fixed ASCII (*.dat)
  • If there are variables in dataset you do not want to transfer, select pick variables button and select the variables you wish to save
  • REMEMBER ORDER OF VARIABLES! This is important because Mplus doesn’t know which line of numbers respresents what, so you need to tell it in the syntax.
  • Double check the .dat file in a text editor to make sure there are no issues with it
    • Some common issues:
      • 1) there are funky symbols in the top left corner of the .dat file that need to be removed
      • 2) there is no coherent spacing of numbers in the .dat (i.e., when you open the data file there is no discernable patterns and it’s a chaotic mess of numbers, letters, and symbols – there should be no letters or symbols! or variable names for that matter)
        • checking these can save you hours of troubleshooting
  • Save file in the same folder as your Mplus syntax (otherwise you would have to specify the full file path – by why not just store it in the same folder so you can just use the file name).
  1. Want to know a quick way to get your variable labels into Mplus?
  • To copy and paste variable names from SPSS, go to Utilities, select Variables…
  • Highlight the variables in your dataset for Mplus (if there were variables you didn’t transfer over, don’t forget to drop these) and press paste to have the variables sent to syntax.
  • Copy and paste into your Mplus syntax.


Transferring from other programs to come!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s