Message/Author 


Does Mplus read data from excell or from spss? 


No. Data must be in as ASCII file (text file). 


Thanks! 


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). 


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



Fernando, 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. Zhiyong zyang@jmsb.concordia.ca 


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 userspecified value. Otherwise, the .'s are saved as blanks. 


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. 


Fernando, Could you send me your SPSS macro as well? I am not able to convert my file to an acceptable .dat version yet. gratefully, Todd B. Kashdan, Ph.D. Assistant Professor Department of Psychology George Mason University tkashdan@gmu.edu 


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. 


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 datfile, 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. 


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. Ioanna 


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? 


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? Thanks, Anna as520@york.ac.uk 

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 


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 http://www.danielsoper.com/n2mplus/ 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. 


I am not familiar with N2Mplus. You should check with whoever makes it to see if they know of a solution. 


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. peter 

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). 


Please send your input, data, output, and license number to support@statmodel.com. 

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 Torvon 


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: http://www.revelationofsilence.com/wpcontent/uploads/2012/01/spss_save.png (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 Torvon 


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!! John 


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 support@statmodel.com. 


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? Best Ninni Title: Entering data from .dat file Data: File is forMplus19.dat; Variable: Names are 93 variables ; MISSING are all(999); Analysis: Type = basic; 


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. 


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? Best Ninni 


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 support@statmodel.com. 

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 


Have you tried using the file with Mplus? 

Back to top 