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).
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.
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.
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.
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?
Tim Wind posted on Friday, March 19, 2010 - 6:27 am
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?
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
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.
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
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).
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).
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
(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.
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.
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 email@example.com.
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?
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.
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 firstname.lastname@example.org.