Reading a .xls file or .sav file PreviousNext
Mplus Discussion > Structural Equation Modeling >
 Renata Estrella posted on Friday, December 09, 2005 - 7:43 am
Does Mplus read data from excell or from spss?
 Linda K. Muthen posted on Friday, December 09, 2005 - 8:03 am
No. Data must be in as ASCII file (text file).
 Renata Estrella posted on Friday, December 09, 2005 - 8:06 am
 Fernando Terrés de Ercilla posted on Thursday, November 23, 2006 - 11:44 pm
I've just written an SPSS macro (include file) to automatically convert SPSS data into a data file (.dat) and Mplus program (.inp) that can be used in Mplus. If somebody is interested, let me know (alternatively, I could post it here).
 Linda K. Muthen posted on Friday, November 24, 2006 - 9:28 am
You can post it here as long as it fits in a single post. Otherwise, it should be by request.
 Zhiyong Yang posted on Thursday, December 07, 2006 - 5:51 pm

Could you please send your SPSS macro to me ASAP? Many thanks! I am finding a very hard time to convert my SPSS data into a .dat file that can be accepted by MPlus.

Thanks again.

 Linda K. Muthen posted on Friday, December 08, 2006 - 9:58 am
Have you tried opening the file in the SPSS editor and using the SAVE AS function? It has been reported to me that this is possible in SPSS. There are issues that you need to change the missing values from . to a user-specified value. Otherwise, the .'s are saved as blanks.
 Linda K. Muthen posted on Sunday, March 04, 2007 - 9:46 am
I understood from Fernando that his macro did not work. It is my understanding that you open an SPSS file in their editor and save as either a text file or a file delimited by tabs, blanks, or commas. It is unclear from you post whether your error messages come from trying to create an ASCII file or from using the ASCII file.
 Todd B. Kashdan posted on Tuesday, June 26, 2007 - 9:23 am

Could you send me your SPSS macro as well? I am not able to convert my file to an acceptable .dat version yet.


Todd B. Kashdan, Ph.D.
Assistant Professor
Department of Psychology
George Mason University
 Linda K. Muthen posted on Tuesday, June 26, 2007 - 9:30 am
My understanding is that you open your SPSS file and use the Save As function to save it as a text file. I don't think the macro worked.
 Mogens Fenger posted on Friday, August 15, 2008 - 4:45 am
It is sometimes tedious to convert SPSS files, but in fact is should be easy. When I save a SPSS file as a .dat file I include the headings. Then I use TextPad (on the net) to open the dat-file, copy the headings into Mplus NAMES ARE, remove the headings from the TextPad file, and then very important: commas are used in the data as decimal points but should be dots. This is easily corrected in TextPad. The file should then be OK.
 Ioanna Vrouva posted on Thursday, September 11, 2008 - 7:13 am
Dear all,
I have managed to save my SPSS file as a ASCII file (.dat). However,I am somewhat unclear about the MVs issue. At first I deleted all MVs before converting the SPSS file into an MPlus data file but what is the best way of keeping MVs in a CFA? Recode all of them as an X number in SPSS file first and then convert to the MPlus data file?
thank you very much.
 Linda K. Muthen posted on Thursday, September 11, 2008 - 11:33 am
If by MV you mean missing value, save the full data set with a specified missing value flag. The use the MISSING option in Mplus to specify the missing value flag(s).
 JackBox posted on Friday, September 19, 2008 - 4:40 am
I have converted my spss data to .dat file. Missing cases are marked as 999 and I've changed commas to dots. The values are delimited by tabs. From my point of view everything should be ok.

For some reason the analyze is now done only to half of the data so that only 50% of the both groups data is used. What is the reason for this? How can I fix this problem?
 JackBox posted on Friday, September 19, 2008 - 5:18 am
I've found the reason: In the VARIABLE list there was one extra variable which was earlier made (and used) with DEFINE command. In the current input this extra variable was not needed anymore and I took the DEFINE command away, but forget to delete this extra variable from the variable list.

The problem is now solved, but why did this use of 50% of the data happend?
 Linda K. Muthen posted on Saturday, September 20, 2008 - 4:48 pm
If you have too variables on the NAMES statement, the program would have needed to read two lines in the data file to find the correct number of pieces of information. If you create a new variable in DEFINE, it should not be placed on the NAMES statement. It should be placed on the USEVARIABLES list.
 Anna Sims posted on Friday, October 24, 2008 - 1:15 am
Hi Fernando,
Would you be able to email me the macro as well?


 Tim Wind posted on Friday, March 19, 2010 - 6:27 am
Hi all,

I have a problem converting my SPSS data into MPlus as well. When I convert the SPSS data into a Asci file (.dat), I lose the variable names.
1. How can I solve this problem?
2. Can I only use the names x, y, w, or clus (cluster) for variables?

Thank you in advance,

Best, Tim
 Linda K. Muthen posted on Friday, March 19, 2010 - 6:35 am
I am not sure what you mean by lose the variable names. The NAMES option of the VARIABLE command is used to give the variable names. Variable names must begin with a letter. They can contain only letters, numbers, and the underscore symbol.
 JackBox posted on Friday, March 19, 2010 - 7:12 am
If you use SPSS18, try to save as "tab delimited" and check the "Write variable names to spreadsheet" box. That should solve the first problem. In the data file the first row will be the variable names from SPSS.

In Mplus variable names can not be longer than 7 marks in addition to Lindas notes.
 finnigan posted on Friday, March 19, 2010 - 7:53 am
There is a piece of software that converts SPSS files to an MPLUS format. Its called N2MPLUS.
Here's the link

It might be of use.
 Keri Pinna posted on Sunday, August 08, 2010 - 7:28 pm
I'm new to MPlus and am using N2MPlus to convert my SPSS data. For some reason the last case in my SPSS file is not being read into the converted file. Any ideas on why that might be? I was previously able to copy and paste data from that final case into the new file, but now that no longer works.
 Linda K. Muthen posted on Monday, August 09, 2010 - 6:31 am
I am not familiar with N2Mplus. You should check with whoever makes it to see if they know of a solution.
 Peter Elliott posted on Monday, August 23, 2010 - 5:42 pm
N2Mplus is a great program, but it does drop the last case in a SPSS data file. You need to add a dummy row to the end of your SPSS data file. It doesn't matter what values you put into this row as N2Mplus ignores it anyway.

 Keri Pinna posted on Friday, September 17, 2010 - 12:13 pm
Peter -

Thanks for the tip. I added the dummy variable and N2MPlus is now reading all of my variables (unfortunately, when I contacted the author via the N2MPlus website, I received no reply).

My next issue is that MPlus is not consistently reading all of the cases from the N2MPlus file. I have tried the standard checking for missing values and ensuring that lines are of equal length. Any other suggestions? It was reading all of the variables until I revised the file as I needed to calculate new variables (because I'm still new to MPlus, I calculated them in SPSS and reconverted to MPlus using N2MPlus).
 Linda K. Muthen posted on Friday, September 17, 2010 - 2:14 pm
Please send your input, data, output, and license number to
 EFried posted on Tuesday, January 17, 2012 - 3:24 pm
Dear Dr. Muthén.

If I save SPSS v.20 data via "save as -> fixed ASCII .dat", the means in MPLUS are completely messed up.

If I save SPSS v.20 data via "save as -> tab delimited .dat", things seem ok. (I'd love if you added a section to your handbook about this. Maybe I'm just blind. What is the method you recommend?)

However, the means are slightly different from the SPSS file.

SPSS 2.452, 5,424, 5.826, 6.238, 5.591
MPLUS 2.394, 5.469, 6.015, 6.479, 5.768

To make sure I did nothing wrong, I double checked descriptive statistics and frequencies in SPSS, rounded every variable in SPSS again just to make sure they have no digits after comma, and double checked all missings (all have -999, and are correctly identified in MPLUS).

In MPLUS I simply use "sampstat" to get means.

What could be the reason for this?

Thank you
 Linda K. Muthen posted on Tuesday, January 17, 2012 - 7:02 pm
I am not sure what you mean by fixed ASCII.dat. You can save an SPSS file as txt, comma delimited, or tab delimited. See the DATA command in the user's guide where the type of data Mplus can read is described.

Mplus uses the full sample size for the means. SPSS uses all available data for each variable so the sample size can vary for each variable depending on the amount of missing data.
 EFried posted on Wednesday, January 18, 2012 - 9:51 pm
Linda, thank you.

(1) Data
"Fixed ASCII" is an option in SPSS, screenshot here:

(2) Means
I didn't know that. The differences are quite big though (5.8 vs. 6.0 for N>750!), I don't understand it. If I have four values, 1=1.0, 2=2.0, 3=3.0 and 4=missing, the true mean is 2.0, right? How can they be different?
What I did now: sampstat using all 5 measurement points, and sampstat only using one measurement. The second one calculation in MPLUS is much closer to the SPSS mean than the first calculation.

Also: which mean value do I report in a paper?

Thank you
 Linda K. Muthen posted on Thursday, January 19, 2012 - 6:26 am
I suspect when you use fixed ASCII, you are reading the data as free format and forgetting to use the FORMAT option.

You should report the sample statistics that the analysis is based on. If you do your analysis in Mplus, ask for SAMPSTAT in the MODEL command or TYPE=BASIC.
 John Mahoney posted on Tuesday, February 12, 2013 - 12:37 am
Any suggestions about how to convert SPSS data to be used with the Mac version of Mplus?

I've tried converting into a text file (.dat) and everything 'looks' in place (compared to other data sets I've used on Windows), but I continue to receive an 'error' message saying I have no observations.

I know my input is correct because I've tried it on example data sets (again, which look highly similar to the one I've generated). However, I still can't analyse my data set.

Help please!!

 Linda K. Muthen posted on Tuesday, February 12, 2013 - 6:10 am
SPSS seems to be saving the data as unicode. Open the data file in the Mplus editor. You may see an invalid characted at the beginning of the first record. If so, delete it and save the data. Another problem could be blanks in the data set. If you can't solve this, send the input, data, output, and your license number to
 Ninni Persson posted on Wednesday, May 08, 2013 - 1:43 pm
Dr. Muthen,

I am having such a hard time converting SPSS data to m+. When I open the .dat file
in m+ to edit it, I find some variables having 6 decimals (as in the original file),
and others 10. I have to edit everything by hand in mplus. Is there a more efficient
way of dealing with converting data from SPSS (19)?

Further, when I run mplus script to check that the means are ok, without specifying missing values, I get descriptives for 143 observations. I have 144 in my dataset. When I enter a line for missing values (-99), I get the following message. NO CONVERGENCE IN THE MISSING DATA ESTIMATION OF THE SAMPLE STATISTICS. Also, I get a message about having only 72 observations. I have few missing cases and my data is MCAR. What can be done about this? Is something wrong with coding of missing values?



Entering data from .dat file


File is forMplus19.dat;


Names are

93 variables


MISSING are all(999);


Type = basic;
 Linda K. Muthen posted on Wednesday, May 08, 2013 - 2:12 pm
I am not familiar with converting from SPSS to an ASCII file. This would be a question for SPSS about why they save the decimals differently. It sounds like you may have blanks in the data set if you are getting less observations. I believe that SPSS uses blanks for missing which is not allowed with free format data.
 Ninni Persson posted on Wednesday, May 08, 2013 - 6:05 pm
Hello Linda,

Thank you for input.

One thing that confuses me is that
when I take missing are all (999)
out of my syntax, all 143 cases are analyzed
instead of 72. Do you have any idea?

 Linda K. Muthen posted on Wednesday, May 08, 2013 - 6:27 pm
That's because there are no missing values. It sounds like the missing values may be on covariates and cases with missing values on the covariates are excluded. There will be a warning about this in the output. If you can't figure it out, send the files and your license number to
 Nara Jang posted on Sunday, March 23, 2014 - 12:51 am
Dear Dr. Muthen,

I converted SPSS file to text file (save as tab delimited). But whenever I open the text file, all variables are not in the text file. Would you tell me how I can solve this problem.

Also, N2Mplus program has Trojan, so I cannot use this.

Best regards,
Nara Jang
 Linda K. Muthen posted on Sunday, March 23, 2014 - 6:27 am
Have you tried using the file with Mplus?
 Dale Hample posted on Saturday, April 26, 2014 - 9:42 pm
The N of 143 is interesting. I am learning MPlus this weekend and began by converting an SPSS file into a .csv file. I deleted the first row of the .csv, which contained variable names. But the SPSS file had a few missing values. Not realizing the problem, I ran some CFAs in MPlus, and saw that 143 cases were being read, instead of the 270 or so that are actually in the data file.
 Linda K. Muthen posted on Sunday, April 27, 2014 - 6:25 am
I suspect you have blanks in your data set. This is not allowed with free format data. SPSS uses blanks for missing values in some cases.
 Dale Hample posted on Sunday, April 27, 2014 - 7:39 am
You are certainly right. I was just noticing the 143, which an earlier poster in this thread said was where his/her data set choked,too.
 Linda K. Muthen posted on Sunday, April 27, 2014 - 8:28 am
That is just a coincidence.
 Samantha Penney posted on Tuesday, June 03, 2014 - 1:19 pm
I've saved my SPSS file as a .dat file to my desktop and included the following in my syntax:

File is "DASfile.dat";

However I keep getting the error that it can't be found.

The number of observations is 0. Check your data and format statement.
Data file: DASfile.dat
Invalid symbol in data file:
"D1Pr" at record #: 1, field #: 5
 Linda K. Muthen posted on Tuesday, June 03, 2014 - 1:38 pm
It sounds like you have the variable names in the first line. Delete this line.
Back to top
Add Your Message Here
Username: Posting Information:
This is a private posting area. Only registered users and moderators may post messages here.
Options: Enable HTML code in message
Automatically activate URLs in message