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.
 Kelly M Allred posted on Wednesday, February 04, 2015 - 8:18 am
I'm trying to conduct an EFA, but when I try to run the model, I get the following error message:

*** ERROR
Non-missing blank found in data file at record #1, field #: 9

I have looked at the data file, and I cannot find any non-missing blanks in the whole text file. Any ideas as to what may be interfering?

Many thanks!
 Linda K. Muthen posted on Wednesday, February 04, 2015 - 4:00 pm
Blanks are not allowed with free format data only with fixed format data.
 Jennie Jester posted on Monday, June 20, 2016 - 1:43 pm
To transfer files from SAS into Mplus, I have been using the PUT command in SAS for many years without any problems. Lately, though, I get errors.
I got this error:
*** ERROR
Non-missing blank found in data file at record #30, field #: 333

Can you help me with the syntax which will create a data file from SAS?

Thanks,

Jennie
 Linda K. Muthen posted on Monday, June 20, 2016 - 4:29 pm
I don't know SAS so I can't help you with that. If you send your output, data set, and license number I can see what causes the error message.
 Jennie Jester posted on Tuesday, June 21, 2016 - 8:26 am
Thank you for your response. I figured out that SAS was putting value labels into the file and I was able to strip the value labels and now things are better. Strange that it started happening after years of using the same statement with no issues. Of course,it's a SAS issue, not an Mplus issue.
 Adam Shen posted on Thursday, December 28, 2017 - 12:08 pm
Hello,I've been trying to correct the errors I consistently got concerning a particular variable in a record of my file. To begin with, I loaded my dat file correctly, ran cfa analyses correctly, but as soon as I included this particular variable (GRADE_POINT) in usevariables and in the model for an additional path analyses (GRADE_POINT on ALEKS_deep SPQ_deep SPQ_surface ALEKS_surface), I got:
*** ERROR
The number of observations is 0. Check your data and format statement.
Data file: Trial.dat
*** ERROR
Invalid symbol in data file:
"Warning" at record #: 1, field #: 101

I then checked the dat file in Mplus, and didn't find said "warning" symbol; tried deleting the whole record from the input file, didn't help either.

Any suggestion about what happened, and how to fix it? I'll be happy to send over my input file if helpful.
 Linda K. Muthen posted on Thursday, December 28, 2017 - 1:21 pm
Please send the output and the data set along with your license number to support@statmodel.com.
 Marilyn Ahun posted on Thursday, April 19, 2018 - 8:19 am
Hi,
I am having trouble reading my SAS dataset in Mplus. I read through this FAQ and as suggested, saved my SAS file in .txt format and removed he variable names from the first record of the data file but I still got an error message:

*** ERROR
Unexpected end of file reached in data file.

What is wrong?
I just want to make sure my dataset is being properly read in mplus before starting complex analyses

Marilyn
 Ethan Schoolman posted on Thursday, April 19, 2018 - 8:29 am
I am new to Mplus, but I plan on using StatTransfer (14) to convert data from Stata (.dta) format to Mplus.

Best,
Ethan
 Linda K. Muthen posted on Thursday, April 19, 2018 - 9:39 am
Marilyn:

The usually means that you have blanks in your data set which is not allowed with free format data or that you have more variable names on the NAMES list than you have columns in the data set. If this does not help, send the output, data set, and your license number to support@statmodel.com.
 Linda K. Muthen posted on Thursday, April 19, 2018 - 10:12 am
Ethan:

StatTransfer is not our product and I am not familiar with it. If no one else on this forum is, you might want to ask for help on SEMNET.
 Ethan Schoolman posted on Thursday, April 19, 2018 - 10:26 am
I've used this for years. It's very useful for going back and forth with Stata, SPSS, Excel, GIS, etc. and also Mplus.

https://stattransfer.com/
 Hillary Gorin posted on Tuesday, May 22, 2018 - 1:40 pm
Hello,

If running a three-factor CFA in MPLUS with data originally saved from MPLUS using Fixed Ascii, local encoding gives the following:

*** ERROR in VARIABLE command
MISSING = BLANK is not allowed for free format data.

What does this mean?

What can I do to fix it? I have retained all possible complete cases but need to keep some blank data in.

Thanks!
Hillary
 Linda K. Muthen posted on Tuesday, May 22, 2018 - 2:11 pm
If you saved the data using Mplus, the missing value flag is an asterisk (*). If you are not using a format statement, it is assumed you are reading the data free format and blanks are not allowed with free format data.
 Hillary Gorin posted on Tuesday, May 22, 2018 - 2:20 pm
Hello Dr. Muthen,

Thank you for your response!

I saved the data in SPSS and created a .Dat file.

I specify FORMAT IS 21F8.2;

and used MISSING ARE BLANK;

Do I need to modify these statements?

Thanks,
Hillary
 Linda K. Muthen posted on Tuesday, May 22, 2018 - 2:29 pm
Please send the output, data set, and your license to supprt@statmodel.com.
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: