SAS data to Mplus PreviousNext
Mplus Discussion > Structural Equation Modeling >
Message/Author
 Anonymous posted on Thursday, December 12, 2002 - 10:04 am
I am new to Mplus.
How to transform a SAS dataset into the form by which Mplus can manipulate?


Daniel
 bmuthen posted on Thursday, December 12, 2002 - 10:31 am
You save your data in ASCII format.
 Anonymous posted on Monday, December 16, 2002 - 10:59 am
Hinted by FAQ from a University web, we can export SAS data in any one of the three forms which Mplus can recognize:
tab-delimited
space-delimited
comma-delimited

I export a SAS data as tab-delimited form (*.txt file) where the first variable is sbv26t1. I run a checking program, then I get a hint:

*** ERROR
Invalid symbol in data file:
"SBV26T1" at record #: 1, field #: 1
What is wrong?

Daniel
 Linda K. Muthen posted on Monday, December 16, 2002 - 11:04 am
You need to remove the variable names from the first record of the data file.
 Anonymous posted on Sunday, September 18, 2005 - 6:39 pm
Hi Bengt,

I am new to Mplus. Could you give me some advices on the error messages? My input is:

TITLE: this is an example of a CFA with
categorical factor indicators
DATA: FILE IS J_201.dat;
VARIABLE: NAMES ARE Item1-Item12;
CATEGORICAL ARE Item1-Item12;
MODEL: f1 BY Item2 Item5 Item6 Item9;
f2 BY Item1 Item3 Item4 Item7 Item8 Item12;
f3 BY Item10 Item11

The error messages are:

ERROR
The number of observations is 0. Check your data and format statement.
Data file: J_201.dat
*** ERROR
Invalid symbol in data file:
"2.001.001.001.001.00" at record #: 1, field #: 1

Thank you for your help
 Linda K. Muthen posted on Tuesday, September 20, 2005 - 8:12 am
It looks like your data are fixed format and you are reading them as free format. Try adding a FORMAT statement. If this does not help, send your input, data, output, and license number to support@statmodel.com.
 Anonymous posted on Wednesday, September 21, 2005 - 4:38 am
You may also use third party software such as DBMS copy to convert the SAS data file to ASCII format. When doing this be sure to strip the variable names from the file as mentioned in a previous post. Once inside Mplus simply arrange your variable names in accordance with the arrangement of the data lines.
 HWard posted on Wednesday, December 14, 2005 - 12:25 pm
Hi - just testing out MPlus, trying to run a simple logistic regression (ordinal education variable NEWEDUC predicting overweight vs. healthy weight (DBMI). here's the code:


TITLE: TEST

DATA:
FILE IS "C:\Documents and Settings\Owner\My Documents\MINI_TRY.TXT";
FORMAT IS FREE;

VARIABLE: NAMES ARE AGE NEWEDUC DBMI;
USEVARIABLES DBMI NEWEDUC AGE;
CATEGORICAL ARE DBMI;
MISSING ARE . ;

ANALYSIS: TYPE = LOGISTIC ;
MODEL: DBMI ON NEWEDUC;

And here are the error messages:
*** WARNING in Model command
Variable is uncorrelated with all other variables: AGE
*** WARNING in Model command
All least one variable is uncorrelated with all other variables in the model.
Check that this is what is intended.
*** ERROR
LOGISTIC analysis is only available with one categorical y-variable.

the warnings re: age are confusing as previous analyses with SAS indicated that there are significant correlations between AGE and DBMI, and AGE and NEWEDUC. Also, the ERROR message doesn't makes sense to me.

Your thoughts?
 Linda K. Muthen posted on Wednesday, December 14, 2005 - 12:56 pm
You don't have the variable age in the MODEL command. Is it a covariate?
 HWard posted on Wednesday, December 14, 2005 - 2:22 pm
Ahhh, yes. That explains the error there - seems to take care of the warning too. Thanks!
 HWard posted on Wednesday, December 14, 2005 - 2:51 pm
One more question: my SAS data set identifies missing variables as a period (.) but when I export the data using the SAS export wizard to either comma- or tab-delineated form (saved as a .txt file), the missing values show up as blank and aren't read by MPlus since the data is in free format. Has anyone else run into this problem?
 Linda K. Muthen posted on Wednesday, December 14, 2005 - 3:55 pm
I don't know the solution to this problem but I have seen it. I would imagine that SAS has an option to say what you want the missing value to be saved as.
 Magdalena  posted on Monday, February 27, 2006 - 12:33 pm
Hello,

I am trying to run a two-level confirmatory factor analysis with multiply imputed data. Thus, I have followed the instructions on addressing imputation. After running the analysis, I get no output file. Also, when I check the output file it says "Input reading terminated normally" but it has no results. Do you know why this could be?

Thanks very much.
 Linda K. Muthen posted on Monday, February 27, 2006 - 12:48 pm
I would need to see your input, imputed data, output, and license number at support@statmodel.com. Try to replicate it with only two of the inputed data sets.
 Haibei Liu posted on Monday, June 16, 2008 - 1:00 pm
Hi,
I am new to Mplus.
I export a dataset in sas to mplus, first saved as a .txt file. It looks ok, but after I checked sample statistic, the data didn't read correctly. The mean of wmistan is actually the mean of dxagecat which is a categorical variable and just in front of wmistan .
I attached part of the short programming below:
VARIABLE: NAMES ARE cogid dxage gender regimen dx_inter dxagecat wmistan memoryt memorys;
missing are .;
USEVARIABLES ARE wmistan memoryt memorys t_memory;
define: t_memory=-1*memorys;


MODEL:WM BY t_memory wmistan memoryt;

output: sampstat ;


Thanks very much for your time and any suggestions.
 Linda K. Muthen posted on Monday, June 16, 2008 - 2:12 pm
This is a support question. Please send your input, data, output, and license number to support@statmodel.com. It sounds like you don't have the variable names in the same order as the variables in the data set.
 Jill McClain posted on Tuesday, March 17, 2009 - 1:39 pm
Hi Linda. Can you tell me if Mplus does anything with the variables in the dataset if they're not in the usevariables list? I'm having a problem where I do the same analysis in a dataset containing two additional variables (racesex and race), which are not in my usevariables or model statements, but I get different results than I get when those variables are not in the dataset. I have checked very carefully several times to make sure that the "names are" statement is correct. I get the following message (which doesn't appear when I do the analysis in the dataset without the racesex and race variables), plus only (exactly) half of my observations are used (4649 instead of 9298) and my estimates are way off:

ONE OR MORE PARAMETERS WERE FIXED TO AVOID SINGULARITY OF THE INFORMATION MATRIX. THE SINGULARITY IS MOST LIKELY BECAUSE THE MODEL IS NOT IDENTIFIED, OR BECAUSE OF EMPTY CELLS IN THE JOINT DISTRIBUTION OF THE CATEGORICAL VARIABLES IN THE MODEL. THE FOLLOWING PARAMETERS WERE FIXED: 71


THE MODEL ESTIMATION TERMINATED NORMALLY
 Jill McClain posted on Thursday, March 19, 2009 - 8:10 am
Never mind the above post. I discovered that the model was ignoring my "data is" path because it was on two lines and was instead using an older version of the data that was in the same folder as the program. I should add that I think it would be safer if MPlus always issued a warning when there's something wrong with the path specification and it instead reads data from another folder. I'll admit that I probably shouldn't have different versions of the data with the same name in different folders, but I'd still prefer to get a warning. Maybe for the next version?
 Georgia Macnevin  posted on Wednesday, July 25, 2012 - 10:59 pm
Hi, I'm very new to Mplus and I'm have some issues with getting my analysis to run.

INSTRUCTIONS:

TITLE:
DATA: FILE IS CANT.Mplus.2.dat;
Define: IntEO = Eth*Ost;
VARIABLE: NAMES ARE sub cond age gend Belon Self Cont Mean Need RDAt DehMec DehAn;
NAMES ARE RDbe TotRD TotDeh DPos DNeg ACt RRom Eth Lang Ost INT;
USEVARIABLES ARE Belon Self Cont Mean Need DehAn Eth Lang Ost IntEO;
ANALYSIS: estimator = ;
bootstrap = 1000;
MODEL: Need ON Eth Ost IntEO Lang;
DehAn ON Need;
DehAn ON Eth Ost IntEO Lang;

*** WARNING in MODEL command
Variable is uncorrelated with all other variables: BELON
*** WARNING in MODEL command
Variable is uncorrelated with all other variables: SELF
*** WARNING in MODEL command
At least one variable is uncorrelated with all other variables in the model.
Check that this is what is intended.

I know someone posted something similar about but it didn't really help me. As I haven't included the variables BELON etc I wasn't sure why they would have anything to do with the analysis.

Any help would be great.
Thanks
 Linda K. Muthen posted on Thursday, July 26, 2012 - 6:25 am
You have the variable belon and self on the USEVARIABLES list but not in the MODEL command. All variables on the USEVARIABLE list are used in the analysis. If this is not what is intended, you should remove belon and self from the USEVARIABLES list.
 Nathan Smith posted on Thursday, July 11, 2013 - 1:49 pm
After saving my SPSS file into a .dat file, I continually get the following error messages:

*** ERROR
The number of observations is 0. Check your data and format statement.
Data file: Data I'm Using.dat
*** ERROR
Invalid symbol in data file:
"1" at record #: 1, field #: 1

I have checked the data and I can't see the symbols mentioned. The same thing will happen whey I try to use a .txt file.
 Linda K. Muthen posted on Thursday, July 11, 2013 - 2:13 pm
Open the data file in the Mplus Editor. You will see the invalid character at the beginning of the data file. Delete it and save the data. The latest version of Mplus seems to have introduced this problem.
 Linda K. Muthen posted on Thursday, July 11, 2013 - 2:25 pm
Oops! It is the latest version of SPSS that introduced the problem.
 Timothy posted on Thursday, September 05, 2013 - 9:04 am
Dear Prof. Muthen,

I experienced the same problem with the new SPSS version when I converted the SPSS data file to MPlus data file. I tried your suggestion using the Mplus editor to fix the invalid character at the beginning of the data file. However, it still didn't work. Could you please advise what else I could do to fix the problem?

Timothy
 Linda K. Muthen posted on Thursday, September 05, 2013 - 10:19 am
Please send the input, data, output, and your license number to support@statmodel.com.
 Hardy Holte posted on Thursday, October 17, 2013 - 12:36 pm
Dear Prof Muthen,
I have the same problem with SPSS 21. I cannot solve the problem of the invalid symbol in the data file by using the mplus editor. What can I do?

Hardy
 Linda K. Muthen posted on Thursday, October 17, 2013 - 3:02 pm
Are you using Windows or the Mac?
 Hardy Holte posted on Friday, October 18, 2013 - 1:29 am
I am using Windows 7.

Hardy
 Linda K. Muthen posted on Friday, October 18, 2013 - 5:44 am
If you open the data file in the Mplus Editor, you can see the invalid symbol. It is the first entry in the data file. Delete it and save the data.
 Sandra posted on Tuesday, March 18, 2014 - 8:42 am
Hi Linda,

I am a new user of Mplus and have imported my data from a fixed format. To double check if I did it well I added at the end of Mplus editor:

Output:
SAMPSTAT;

I was expecting to get descriptive results to compare with the ones I got from SPSS. However, it gives me only the variance, but not the means. And the following error appears:

*** ERROR
One or more variables have a variance of zero.
Check your data and format statement.

Is this normal? How can I get the means?

many thanks in advance.
 Linda K. Muthen posted on Tuesday, March 18, 2014 - 9:07 am
I suspect you have blanks in your data set. You will get, means, variances, and covariances once to data reading problem is solved. SPSS uses blanks for some missing data. Please send the data, output, and your license number to support@statmodel.com if you cannot see the problem.
Back to top
Add Your Message Here
Post:
Username: Posting Information:
This is a private posting area. Only registered users and moderators may post messages here.
Password:
Options: Enable HTML code in message
Automatically activate URLs in message
Action: