BookmarkSubscribeRSS Feed
niloo
Obsidian | Level 7

Hi,

I am trying to learn SAS using the videos on YouTube:How to Use SAS - Lesson 3 - Importing External Data - YouTube.

When I run the statement to import a text file I see the following warnings in the log:

114  data infile_main;

115  infile "C:\eventus\main.txt" LRECL=100 DLM=' ' firstobs=2;

116  input

117  x y z;

118  run;

NOTE: The infile "C:\eventus\main.txt" is:

      Filename=C:\eventus\main.txt,

      RECFM=V,LRECL=100,File Size (bytes)=21,

      Last Modified=13Aug2015:19:25:41,

      Create Time=13Aug2015:19:25:38

NOTE: Invalid data for x in line 2 1-5.

NOTE: Invalid data for y in line 3 1-5.

NOTE: LOST CARD.

NOTE: Invalid data errors for file '"C:\eventus\main.txt"' occurred outside the printed range.

NOTE: Increase available buffer lines with the INFILE n= option.

x=. y=. z=. _ERROR_=1 _N_=1

NOTE: 2 records were read from the infile "C:\eventus\main.txt".

      The minimum record length was 5.

      The maximum record length was 5.

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

NOTE: The data set WORK.INFILE_MAIN has 0 observations and 3 variables.

NOTE: DATA statement used (Total process time):

      real time          0.02 seconds

      cpu time            0.01 seconds

Here are my statements:

data infile_main;

infile "C:\eventus\main.txt" LRECL=100 DLM=' ' firstobs=2;

input

x y z;

run;

This is not the only time I have problem importing the data using data statements. I do not have any trouble importing the data using proc import or File>Import Data. Could you please tell me what is my mistake here?

Thanks,

Niloo

2 REPLIES 2
varunk
Calcite | Level 5

Hi Niloo,

Kindly proive the sample raw data file which you want to import.

Thanks,

VK

ballardw
Super User

If you post some of the data I believe you will find that there are character values and possibly only one word or string of 5 characters.

NOTE: Invalid data for x in line 2 1-5. means that you tried to read character data with a variable that was not declared to be character. You could use input x $ to say that x is supposed to contain character data or associate a character type informat prior to the input statement.

Hint: When you see this

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

you tried to read more than was actually in the input file. The second hint is

NOTE: Invalid data for x in line 2 1-5.

NOTE: Invalid data for y in line 3 1-5.

saying that the y value was attempting to read from the second line of the file and Z from the third line. AS indicated by

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

Run proc import against the same file and then look in the log for the program code generated. You will see significant differences.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1357 views
  • 0 likes
  • 3 in conversation