Hi all,
I am trying to run this macro for Little's MCAR test: http://www.appliedmissingdata.com/littles-mcar-test.sas
However, I am getting error messages saying data are invalid for each of my variables...
I tried having the dat file as comma vs tab delimited, with and without the first row of variable names, double-checked that there are no non-numerical values... Still getting an error message.
What else do you think the cause of error can be?
Thank you in advance.
Thanks for posting the log.
Hi,
I suggest you turn on options MPRINT, run the macro, and review the log. The macro generates several steps. Which step does the error occur in? What does the error message say?
The macro was written to analyze one specific file,
%let datafile = "c:\data\eatingrisk.dat";
Do you have that data file in c:\data?
If you can't see what's happening from the log, I suggest you post the log.
Hi @Amanda_Lemon,
With the example values for &datafile and &varlist given in the code, the macro uses a simple method of reading the raw data (rather than accepting a SAS dataset as input, which I think is more common):
infile &datafile;
input &varlist;
Hence, either your raw data file needs to be
or you need to add options, informats, etc. needed to read your raw data to the values specified in the %LET statements for datafile or varlist.
Example:
%let datafile = 'C:\yourfolder\yourfile.csv' dsd missover;
for a comma-separated file with missing values represented by periods or blanks or null strings.
Thank you for your replies! I followed FreelanceReinhard's recommendation and added
dsd missover
to the datafile line. My raw file is comma-delimited, periods for missing data, no variable names. The number of error messages decreased but no all... I am including the log below. The program gets the # of observations right. However, the # of variables is 175, not 349...
NOTE: A byte-order mark in the file "C:\Users\Desktop\Data_READY_3.dat" (for fileref "#LN00147") indicates that the data is encoded in "utf-8". This encoding will be used to process the file. NOTE: The infile "C:\Users\Desktop\Data_READY_3.dat" is: Filename=C:\Users\Desktop\Data_READY_3.dat, RECFM=V,LRECL=131068,File Size (bytes)=466817, Last Modified=31Mar2020:00:48:29, Create Time=31Mar2020:00:48:29 NOTE: 1274 records were read from the infile "C:\Users\Desktop\Data_READY_3.dat". The minimum record length was 355. The maximum record length was 383. NOTE: The data set WORK.ONE has 1274 observations and 349 variables. NOTE: DATA statement used (Total process time): real time 0.03 seconds cpu time 0.03 seconds NOTE: There were 1274 observations read from the data set WORK.ONE. NOTE: The data set WORK.ONE has 1274 observations and 349 variables. NOTE: PROCEDURE SORT used (Total process time): real time 0.01 seconds cpu time 0.01 seconds ERROR: Variable I not found. NOTE: PROCEDURE MI used (Total process time): real time 0.00 seconds cpu time 0.00 seconds NOTE: The SAS System stopped processing this step because of errors. NOTE: IML Ready ERROR: I is not in the scope of variables for the data set. statement : READ at line 3482 column 1 ERROR: File WORK.EMCOV.DATA does not exist. statement : USE at line 3482 column 1 ERROR: I is not in the scope of variables for the data set. statement : READ at line 3482 column 1 ERROR: (execution) Matrix has not been set to a value. operation : [ at line 3482 column 1 operands : em, *LIT1004, em 0 row 0 col (numeric) *LIT1004 1 row 1 col (numeric) 1 statement : ASSIGN at line 3482 column 1 ERROR: (execution) Matrix has not been set to a value. operation : [ at line 3482 column 1 operands : em, *LIT1005, _TEM1001, em 0 row 0 col (numeric) *LIT1005 1 row 1 col (numeric) 2 _TEM1001 1 row 1 col (numeric) 0 statement : ASSIGN at line 3482 column 1 ERROR: (execution) Invalid operand to operation. operation : J at line 3482 column 1 operands : _TEM1001, *LIT1006, *LIT1007 _TEM1001 1 row 1 col (numeric) 0 *LIT1006 1 row 1 col (numeric) 1 *LIT1007 1 row 1 col (numeric) 1 statement : ASSIGN at line 3482 column 1 ERROR: (execution) Matrix has not been set to a value. operation : MAX at line 3482 column 1 operands : jcol jcol 0 row 0 col (type ?, size 0) statement : ASSIGN at line 3482 column 1 ERROR: (execution) Matrix has not been set to a value. operation : J at line 3482 column 1 operands : j, *LIT1015, *LIT1016 j 0 row 0 col (type ?, size 0) *LIT1015 1 row 1 col (numeric) 1 *LIT1016 1 row 1 col (numeric) 0 statement : ASSIGN at line 3482 column 1 ERROR: (execution) Matrix has not been set to a value. operation : J at line 3482 column 1 operands : j, _TEM1001, *LIT1017 j 0 row 0 col (type ?, size 0) _TEM1001 1 row 1 col (numeric) 175 *LIT1017 1 row 1 col (numeric) 0 statement : ASSIGN at line 3482 column 1 ERROR: DO expression not given value. statement : DO at line 3482 column 1 ERROR: (execution) Matrix has not been set to a value. operation : J at line 3482 column 1 operands : j, *LIT1023, *LIT1024 j 0 row 0 col (type ?, size 0) *LIT1023 1 row 1 col (numeric) 1 *LIT1024 1 row 1 col (numeric) 0 statement : ASSIGN at line 3482 column 1 ERROR: DO expression not given value. statement : DO at line 3482 column 1 ERROR: (execution) Matrix has not been set to a value. operation : [ at line 3482 column 1 operands : d2j, $SUB0001, d2j 0 row 0 col (type ?, size 0) statement : ASSIGN at line 3482 column 1 ERROR: (execution) Matrix has not been set to a value. operation : [ at line 3482 column 1 operands : rj, $SUB0001, $SUB0001 rj 0 row 0 col (type ?, size 0) statement : ASSIGN at line 3482 column 1 ERROR: (execution) Matrix has not been set to a value. operation : PROBCHI at line 3482 column 1 operands : d2, df D2 0 row 0 col (numeric) df 0 row 0 col (type ?, size 0) statement : ASSIGN at line 3482 column 1 ERROR: Operand j does not have a value. statement : PUT at line 3482 column 1 ERROR: (execution) Matrix has not been set to a value. operation : [ at line 3482 column 1 operands : rj, $SUB0001, $SUB0001 rj 0 row 0 col (type ?, size 0) statement : PUT at line 3482 column 1 ERROR: Operand D2 does not have a value. statement : PUT at line 3482 column 1 ERROR: Operand df does not have a value. statement : PUT at line 3482 column 1 ERROR: Operand p does not have a value. statement : PUT at line 3482 column 1 3483 3484 run; NOTE: Module MAIN is undefined in IML; cannot be RUN. 3485 3486 quit; NOTE: Exiting IML. NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE IML used (Total process time): real time 0.14 seconds cpu time 0.07 seconds
Thanks for posting the log.
Just wanted to ask about one more thing -- as I was examining the log, there is a notice "NOTE: Module MAIN is undefined in IML; cannot be RUN." Is this a problem? Why did this notice occur? I do get results even with this notice.
@Amanda_Lemon wrote:
Just wanted to ask about one more thing -- as I was examining the log, there is a notice "NOTE: Module MAIN is undefined in IML; cannot be RUN." Is this a problem? Why did this notice occur? I do get results even with this notice.
I suspect that you just need to replace the run; at the bottom of your code by quit; to get rid of this note, but I can't test it because I don't have a SAS/IML license. There is no module defined in the macro (this would be indicated by a START and a FINISH statement), which is why the RUN statement attempts to run a module of the default name "main" -- but this doesn't exist either, hence the note in the log.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.