BookmarkSubscribeRSS Feed
ksio21008
Calcite | Level 5

Dear All,

I'm trying to reading in a .csv file, but getting an error message on reading in one variable.  The variable is a person's ID number.  When I read in the file using an infile statement, I see a note saying that "Invalid data for this variable." In the log, I see a period added to this variable, which does not exist in the original .csv file.  For instance, I see "84031563578"  in the .csv file, but I see ".84031563578" in the SAS log instead.  I don't know where this period came from.  Can anyone suggest how I can fix this problem?  Thank you!!!

SJK

3 REPLIES 3
ArtC
Rhodochrosite | Level 12

This could be an informat issue.  Take a look at your INFORMAT for that field.  Can we see your INPUT statement?

Ron_MacroMaven
Lapis Lazuli | Level 10

"Id.Number" indicates that the column contains only digits.

This is a far-out suggestion:

Compare your id to

%Put SysMaxLong:&SysMaxLong;

Perhaps your id.numbers are greater than SAS can represent

which causes it to place the 'number' in a decimal format such as you are seeing.

Appropriately it ought to have a leading zero: 0.84031563578

next: 64-bit SAS

Ron Fehd  id maven

ksio21008
Calcite | Level 5

Thank you all!  I fixed an informat statement, and now it works!  I also assigned a proper number of places for the variable.

But I got a new problem.  I have a series of data sets - 11 data sets that represent a data set from each month from Feb 2012 to Dec 2012.

I tried to read in all files at once by using the FILENAME statement, for example,

*FILENAME indat (

  'C:\Users\sjk845\Desktop\data\feb2012.csv'

   ...

   ...

  'C:\Users\sjk845\Desktop\data\dec2012.csv'

);

and refer indat in my INFILE statement.

DATA all;

   INFILE indat DSD TRUNCOVER FIRSTOBS=2 TERMSTR=CR;

............

The problem is that it treats the header from files other than the first referred file (i.e., mar2012 - dec2012) as observation and gives me an error message.  For example, it reads the first row of the March data as an observation, which is in fact the header.

Should I make 11 different INFILE statements for data for each month?  Is there an optional syntax in the FILENAME statement that I can specify that the first row of each external files should be treated as header?

Thank you!

SJK

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
  • 3 replies
  • 1689 views
  • 0 likes
  • 3 in conversation