DATA Step, Macro, Functions and more

Invalid data for some questions

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

Invalid data for some questions

Hi,

I tried to conducting EFA using SAS.

However, there is some errors and I'm not really know how to fix it.

Hopefully you guys are able to help me.

I attached the log from the conducted EFA.

Thank you.

Attachment

Accepted Solutions
Solution
‎02-05-2013 09:05 AM
Super User
Super User
Posts: 7,083

Re: Invalid data for some questions

You need to add a LRECL option to your INFILE statement. The lines in your file are going to be longer than 256 characters. Since you are reading 184 variables you will need to have at least 367 characters even if every value is only one character long.  Also you might add the TRUNCOVER option to prevent it from jumping to a new line if some are shorter than expected.

DATA MASA_GEL;

    INFILE 'C:\Users\nadzatul.abdullah\Documents\My SAS Files\9.3\MASA_GEL.dat' DLM = '09'x DSD LRECL=1000 TRUNCOVER;

    INPUT Gender Race A B C D E F Q1-Q176;

RUN;

The actual error message about invalid data on line 130 is because of the * that is appearing in column 35. The other errors I cannot see what it is complaining about.  Since it looks like most of your data is single digit numbers then perhaps the '*' represents a missing value?  If so then you could ignore this message as SAS will assign missing to the variable where the asterisk appeared.

View solution in original post


All Replies
Regular Contributor
Posts: 195

Re: Invalid data for some questions

Hi Najiah,

I think there is invalid data for variable Q115 and Q139...They both are numeric variable and might be there is character values assigned to them...Check the values of Q115 and Q139 in your main file...

Thanks,


Respected Advisor
Posts: 3,799

Re: Invalid data for some questions

Your more immediate problem is LRECL.

NOTE: 567 records were read from the infile 'C:\Users\nadzatul.abdullah\Documents\My SAS

      Files\9.3\MASA_GEL.dat'.

      The minimum record length was 256.

      The maximum record length was 256.

      One or more lines were truncated.

NOTE: SAS went to a new line when INPUT statement reached past the end of a line.

Trusted Advisor
Posts: 1,137

Re: Invalid data for some questions

Posted in reply to data_null__

Also its better to use the missover in the infile statement in case if the data for few of the variables is missing.

Thanks,

Jagadish

Thanks,
Jag
Regular Contributor
Posts: 195

Re: Invalid data for some questions

Posted in reply to Jagadishkatam

Missover option works better only if the last variabl having missing values but by looking at PDV in attached file, i dont think that there is any need to use missover option...You can use the DSD with MISSOVER if your middle variables are having missing values...

Thanks,


Occasional Contributor
Posts: 7

Re: Invalid data for some questions

Posted in reply to data_null__

sorry, but may I know what do you mean LRECL and how can we fix it?

Respected Advisor
Posts: 3,799

Re: Invalid data for some questions

LRECL stands for logical record length.  You can learn all the details in the SAS documentation.

The LRECL infile statement option default value 256 is too small for your input file.  You probably don't know what it should be but you can set it arbitrarily large.  You might try LRECL=1024.

When the truncation message is gone you should be reading each line properly.  Then you can investigate the invalid data problem.

Solution
‎02-05-2013 09:05 AM
Super User
Super User
Posts: 7,083

Re: Invalid data for some questions

You need to add a LRECL option to your INFILE statement. The lines in your file are going to be longer than 256 characters. Since you are reading 184 variables you will need to have at least 367 characters even if every value is only one character long.  Also you might add the TRUNCOVER option to prevent it from jumping to a new line if some are shorter than expected.

DATA MASA_GEL;

    INFILE 'C:\Users\nadzatul.abdullah\Documents\My SAS Files\9.3\MASA_GEL.dat' DLM = '09'x DSD LRECL=1000 TRUNCOVER;

    INPUT Gender Race A B C D E F Q1-Q176;

RUN;

The actual error message about invalid data on line 130 is because of the * that is appearing in column 35. The other errors I cannot see what it is complaining about.  Since it looks like most of your data is single digit numbers then perhaps the '*' represents a missing value?  If so then you could ignore this message as SAS will assign missing to the variable where the asterisk appeared.

Occasional Contributor
Posts: 7

Re: Invalid data for some questions

Thank you all.

You're guys helps me a lot.

I wish I can give credit to all of youSmiley Happy

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 267 views
  • 6 likes
  • 5 in conversation