|
|
|
||||
|
|
|||||
Suppose that you have an SPSS data file called sample.sav that you would like to convert to Mplus for analyzing there. Here is a listing of the first 10 observations from this file.
list /cases from 1 to 10.
FEMALE RACE SES SCHTYP READ WRITE
. 3.00 1.00 1.00 34.00 35.00
.00 -9.00 2.00 1.00 44.00 41.00
.00 4.00 -99.00 1.00 55.00 39.00
1.00 2.00 3.00 -999.00 60.00 59.00
.00 4.00 1.00 1.00 -9999.00 37.00
.00 4.00 2.00 1.00 34.00 -99999.00
.00 3.00 2.00 1.00 34.00 37.00
1.00 4.00 1.00 1.00 35.00 35.00
.00 4.00 3.00 1.00 44.00 33.00
1.00 4.00 3.00 2.00 36.00 57.00
Note that female has system missing values (denoted by .). Also, the other variables have user defined missing values defined as follows -- race has missing values coded as -9 and ses has missing values coded as -99 and sctyp has missing values as -999 and read has -9999 as missing and finally write has -99999 as a missing value. You can use the following steps to ease the process of converting your file into an Mplus file. We do this in these steps.
- Get descriptive statistics for your current file
- Convert all of the missing values to a single missing value code
- Write out the names of the variables to a file
- Write out the values of the variables to a file
- Make an Mplus program and compare its statistics to those from step 1.
1. Get descriptive statistics for your current file
We can get the descriptive statistics for our file like this. Please note that it is important that you include the /missing=listwise subcommand to assure listwise deletion for comparability of results in step 6.
get file = "c:\mplusfaq\hs1.sav". desc var=all /stat=default variance /missing=listwise.
Here are our results.

2. Convert all of the missing values to a single missing value code
This step converts all of the missing values (the system missings and the user missings) into a single code, -1234. You can pick any integer value you wish, and we recommend choosing a code that is not an existing code for missing values (so we can check below that all missings have been converted to this new code). We selected -1234 since that was a value that was easy to remember, not among the user missing values, and not a valid value for the data.
do repeat V=all. if missing(V) V=-1234. end repeat. execute. list /cases from 1 to 10. desc var=all /stat=default variance /missing=listwise.
We show some of the cases and see that it appears the missings were converted to -1234. Moreover, the output of the descriptives command shows that our N is now 200, indicating that SPSS does not see any missing data.
FEMALE RACE SES SCHTYP READ WRITE
-1234.00 3.00 1.00 1.00 34.00 35.00
.00 -1234.00 2.00 1.00 44.00 41.00
.00 4.00 -1234.00 1.00 55.00 39.00
1.00 2.00 3.00 -1234.00 60.00 59.00
.00 4.00 1.00 1.00 -1234.00 37.00
.00 4.00 2.00 1.00 34.00 -1234.00
.00 3.00 2.00 1.00 34.00 37.00
1.00 4.00 1.00 1.00 35.00 35.00
.00 4.00 3.00 1.00 44.00 33.00
1.00 4.00 3.00 2.00 36.00 57.00
Number of cases read: 10 Number of cases listed: 10

3. Write out the names of the variables to a file
In this next step, we write out just the names of the variables to the file c:\samplenames.dat and we do this so we can supply these variable names in our Mplus program without having to retype them again.
* write names of variables to c:\samplenames.dat . temporary. select if (0). save translate outfile='c:\samplenames.dat' /type=tab /map /replace /fieldnames.
Below we show the contents of this file.
FEMALE RACE SES SCHTYP READ WRITE
4. Write out the values of the variables to a file
Now we write out just variables to the file c:\sample.dat and we do this so we can read this from our Mplus program.
* write data, as tab delimited file, to 'c:\sample.dat' . save translate outfile='c:\sample.dat' /type=tab /map /replace.
Here are the first few observations from c:\sample.dat
-1234 3 1 1 34 35 0 -1234 2 1 44 41 0 4 -1234 1 55 39 1 2 3 -1234 60 59 0 4 1 1 -1234 37 0 4 2 1 34 -1234 0 3 2 1 34 37 1 4 1 1 35 35 0 4 3 1 44 33 1 4 3 2 36 57Now, we can create an Mplus program like the one below to read the data in c:\sample.dat and confirm that the transfer was successful. Note that we use Type = basic meanstructure ; to get listwise deletion of missing data to match the results of step 1.
Title:
Data:
File is c:\sample.dat ;
Variable:
Names are
FEMALE RACE SES SCHTYP READ WRITE ;
Missing = all(-1234) ;
Analysis:
Type = basic meanstructure ;
Output:
sampstat;
And here are excepts of the results below. You can see that the means correspond to the means from step 1, and the variances along the diagonal of the covariance matrix match the variances from step 1. This would suggest that the transfer was successful. You can now modify the Mplus program as you wish to run whatever analysis you like.
Means
FEMALE RACE SES SCHTYP READ
________ ________ ________ ________ ________
0.552 3.412 2.062 1.165 52.485
WRITE
_______
53.149
Covariances
FEMALE RACE SES SCHTYP READ
________ ________ ________ ________ ________
FEMALE 0.249
RACE 0.020 1.104
SES -0.050 0.161 0.525
SCHTYP 0.002 0.046 0.036 0.138
READ -0.367 2.623 2.017 0.293 102.976
WRITE 1.104 2.301 1.239 0.395 54.357
Covariances
WRITE
________
WRITE 85.641
UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services