BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ak2011
Fluorite | Level 6
Hi,
I would greatly appreciate if someone help me resolve this problem. I had an invalid data reading message in SAS. I tried several reading options but I still had errors.
The code and log are found below. May I know the correct statement to use?
Thanks in advance.



data idnew2;
infile cards;
length id $3 ikey 8 acode presence 8;
input id$ 1-8 ikey acode presence;
input id$ ikey acode presence;
datalines;
os1 1 990005 1
os1 1 9900021 0
os1 1 211700 0
os1 2 211700 0
os1 2 9900021 0
os1 2 210701 0
os1 2 990005 1
os2 1 210701 0
os2 1 990005 1
os2 2 9900021 0
os2 3 210701 0
os2 3 990005 1
os3 1 211700 0
os3 3 210701 0
os4 1 210701 0
os4 1 990005 1
os4 1 211700 0
;
run;
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 data idnew2;
74 input id$ ikey acode presence;
75 datalines;
 
NOTE: Invalid data for ikey in line 77 1-15.
NOTE: Invalid data for acode in line 78 1-14.
NOTE: Invalid data for presence in line 79 1-14.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
 
79 CHAR os1.2.211700.0
ZONE 67303033333303222222222222222222222222222222222222222222222222222222222222222222
NUMR F3192921170090000000000000000000000000000000000000000000000000000000000000000000
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
id=os1199 ikey=. acode=. presence=. _ERROR_=1 _N_=1
NOTE: Invalid data for ikey in line 81 1-14.
NOTE: Invalid data for acode in line 82 1-14.
NOTE: Invalid data for presence in line 83 1-14.
 
83 CHAR os2.1.210701.0
ZONE 67303033333303222222222222222222222222222222222222222222222222222222222222222222
NUMR F3291921070190000000000000000000000000000000000000000000000000000000000000000000
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
id=os1299 ikey=. acode=. presence=. _ERROR_=1 _N_=2
NOTE: Invalid data for ikey in line 85 1-15.
NOTE: Invalid data for acode in line 86 1-14.
NOTE: Invalid data for presence in line 87 1-14.
 
87 CHAR os2.3.990005.1
ZONE 67303033333303222222222222222222222222222222222222222222222222222222222222222222
NUMR F3293999000591000000000000000000000000000000000000000000000000000000000000000000
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
id=os2199 ikey=. acode=. presence=. _ERROR_=1 _N_=3
NOTE: Invalid data for ikey in line 89 1-14.
NOTE: Invalid data for acode in line 90 1-14.
NOTE: Invalid data for presence in line 91 1-14.
 
91 CHAR os4.1.990005.1
ZONE 67303033333303222222222222222222222222222222222222222222222222222222222222222222
NUMR F3491999000591000000000000000000000000000000000000000000000000000000000000000000
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
id=os3121 ikey=. acode=. presence=. _ERROR_=1 _N_=4
NOTE: LOST CARD.
93 ;
id=os4121 ikey=. acode=. presence=. _ERROR_=1 _N_=5
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.IDNEW2 has 4 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
 
 
93 ;
94 run;
95
96
97 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
109
1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

You have tabs in your datalines, so use those as delimiter. And remove the surplus input statement.

data idnew2;
infile cards dlm='09'x dsd;
length id $3 ikey 8 acode presence 8;
input id$ ikey acode presence;
datalines;
os1	1	990005	1
os1	1	9900021	0
os1	1	211700	0
os1	2	211700	0
os1	2	9900021	0
os1	2	210701	0
os1	2	990005	1
os2	1	210701	0
os2	1	990005	1
os2	2	9900021	0
os2	3	210701	0
os2	3	990005	1
os3	1	211700	0
os3	3	210701	0
os4	1	210701	0
os4	1	990005	1
os4	1	211700	0
;

View solution in original post

4 REPLIES 4
Kurt_Bremser
Super User

You have tabs in your datalines, so use those as delimiter. And remove the surplus input statement.

data idnew2;
infile cards dlm='09'x dsd;
length id $3 ikey 8 acode presence 8;
input id$ ikey acode presence;
datalines;
os1	1	990005	1
os1	1	9900021	0
os1	1	211700	0
os1	2	211700	0
os1	2	9900021	0
os1	2	210701	0
os1	2	990005	1
os2	1	210701	0
os2	1	990005	1
os2	2	9900021	0
os2	3	210701	0
os2	3	990005	1
os3	1	211700	0
os3	3	210701	0
os4	1	210701	0
os4	1	990005	1
os4	1	211700	0
;
ak2011
Fluorite | Level 6
It works now. Thanks!
PeterClemmensen
Tourmaline | Level 20

Either use

 

dlm='09'x

in your infile statement as you have tabs in your data and get rid of the extra input statement. or simply do this (with spaces)

 

data idnew2;
infile datalines;
input id $ ikey acode presence;
datalines;
os1 1 990005  1
os1 1 9900021 0
os1 1 211700  0
os1 2 211700  0
os1 2 9900021 0
os1 2 210701  0
os1 2 990005  1
os2 1 210701  0
os2 1 990005  1
os2 2 9900021 0
os2 3 210701  0
os2 3 990005  1
os3 1 211700  0
os3 3 210701  0
os4 1 210701  0
os4 1 990005  1
os4 1 211700  0
;

 

 

ak2011
Fluorite | Level 6
That works! Thanks very much!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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