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
This could be an informat issue. Take a look at your INFORMAT for that field. Can we see your INPUT statement?
"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
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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.