BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jacksonan123
Lapis Lazuli | Level 10
 id	x1	x2	count
1	1	2	1
1	2	3	1
1	2	4	1
id	x1	x2	count
2	1	2	2
2	2	3	2
id	x1	x2	count
3	1	2	3
3	2	3	3

The inserted data is a (.fit

 
data one;
infile 'c:\temp\data.fit'  dsd truncover;
input chk $ @;
if chk='id' then delete;
else input @1 id x1 x2 count;
drop chk;
run;
 
proc print; 
run;

When I try to read the text file I get the following error.  Can someone tell me how to correct the code to read the text file?

NOTE: The infile '/folders/myfolders/partialauc/andre.txt' is:
Filename=/folders/myfolders/partialauc/andre.txt,
Owner Name=root,Group Name=root,
Access Permission=-rwxrwxrwx,
Last Modified=07Mar2020:08:33:35,
File Size (bytes)=111

NOTE: Invalid data for id in line 1 1-14.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0

1 CHAR id.x1.x2.count 14
ZONE 66073073066767
NUMR 9498198293F5E4
chk=idx1x2 id=. time=. cmt=. _ERROR_=1 _N_=1
NOTE: Invalid data for id in line 2 1-7.

2 CHAR 1.1.2.1 7
ZONE 3030303
NUMR 1919291
chk=1121 id=. time=. cmt=. _ERROR_=1 _N_=2
NOTE: Invalid data for id in line 3 1-7.

 

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

Your data are TAB delimited add DLM='09'x to your INFILE statement.

 

1 CHAR id.x1.x2.count 14
  ZONE 66073073066767
  NUMR 9498198293F5E4

View solution in original post

10 REPLIES 10
data_null__
Jade | Level 19

Your data are TAB delimited add DLM='09'x to your INFILE statement.

 

1 CHAR id.x1.x2.count 14
  ZONE 66073073066767
  NUMR 9498198293F5E4
jacksonan123
Lapis Lazuli | Level 10
It worked and may I ask you why so that next time I will know?
data_null__
Jade | Level 19

@jacksonan123 wrote:
It worked and may I ask you why so that next time I will know?

 

You need DLM='09'x because your data are tab delimited!

 

SAS is showing your data line as CHARacters and HEX ZONE-NUMR.  Notice the 3rd shown in CHAR as . has ZONE=0 NUMR=9.  

 

1 CHAR id.x1.x2.count 14
  ZONE 66073073066767
  NUMR 9498198293F5E4

SAS doesn't know that '09'x is the delimiter but it does know that '09'x is invalid data for a numeric variable.

jacksonan123
Lapis Lazuli | Level 10
I appreciate the explanation. However I tried the same code on my recent
post and it failed. The data was also a text file and to me similar to my
previous example.

Apparently there is something I still don't grasp about text files with
labels interspersed with data.



NOTE: Invalid data for id in line 1 1-305.

RULE:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+-
---8----+----9----+----0

1 ID TIME CMT Y1 Y2 CP1
CP2 DV MDV

101 X COUNT RHYD RHYL RMETD RMETL
CDLV CLLV CVD

201 CVL CRESI CWRESI CRES CWRES
DV PRED RES

301 WRES 305

chk=ID id=. time=. cmt=. _ERROR_=1 _N_=1

NOTE: Invalid data for id in line 2 1-31
data_null__
Jade | Level 19

@jacksonan123 wrote:
I appreciate the explanation. However I tried the same code on my recent
post and it failed. The data was also a text file and to me similar to my
previous example.

Apparently there is something I still don't grasp about text files with
labels interspersed with data.



NOTE: Invalid data for id in line 1 1-305.

RULE:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+-
---8----+----9----+----0

1 ID TIME CMT Y1 Y2 CP1
CP2 DV MDV

101 X COUNT RHYD RHYL RMETD RMETL
CDLV CLLV CVD

201 CVL CRESI CWRESI CRES CWRES
DV PRED RES

301 WRES 305

chk=ID id=. time=. cmt=. _ERROR_=1 _N_=1

NOTE: Invalid data for id in line 2 1-31

You need to show all relevant code.  

 

 

This message implies that you are tell SAS you have delimited data that does not exist in the file.  For example if you used DSD option which implied DLM=','

 

Invalid data for id in line 1 1-305

The message is saying for the variable being read "ID" in LINE 1 Columns 1-305 

The key data here is 1-305.

jacksonan123
Lapis Lazuli | Level 10
The code was:

data one;

infile '/folders/myfolders/partialauc/testsimjuvpilot3.fit' DLM='09'X dsd
truncover;

input chk $ @;

if chk='id' then delete;

else input @1 id time cmt;

drop chk;

run;

The data file has the titles repeated after every 24 subjects as below:

ID TIME CMT Y1 Y2

1.0000E+00 0.0000E+00 1.0000E+00 0.0000E+00 0.0000E+00

2.4000E+01 2.4000E+01 2.4000E+01 4.2881E+00 4.9617E+01

ID TIME CMT Y1 Y2

1.0000E+00 0.0000E+00 1.0000E+00 0.0000E+00 0.0000E+00
data_null__
Jade | Level 19

@jacksonan123 wrote:
The code was:

data one;

infile '/folders/myfolders/partialauc/testsimjuvpilot3.fit' DLM='09'X dsd
truncover;

input chk $ @;

if chk='id' then delete;

else input @1 id time cmt;

drop chk;

run;

The data file has the titles repeated after every 24 subjects as below:

ID TIME CMT Y1 Y2

1.0000E+00 0.0000E+00 1.0000E+00 0.0000E+00 0.0000E+00

2.4000E+01 2.4000E+01 2.4000E+01 4.2881E+00 4.9617E+01

ID TIME CMT Y1 Y2

1.0000E+00 0.0000E+00 1.0000E+00 0.0000E+00 0.0000E+00

Is the file you show tab delimited? 

jacksonan123
Lapis Lazuli | Level 10
A prior response used this code anydigit designation and it worked as a
solution:

data want;

infile "/...../myData.fit";

input @;

if anydigit(first(left(_infile_))) then do;

input @1 ID TIME CMT Y1 Y2;

output;

end;

run;


data_null__
Jade | Level 19

@jacksonan123 wrote:
A prior response used this code anydigit designation and it worked as a
solution:

data want;

infile "/...../myData.fit";

input @;

if anydigit(first(left(_infile_))) then do;

input @1 ID TIME CMT Y1 Y2;

output;

end;

run;



The use of ANYDIGIT has nothing to do with your misuse of INFILE statement options.

jacksonan123
Lapis Lazuli | Level 10
I agree since the infile statement has been simplified since my designations
were not correct for the file type I have.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 10 replies
  • 904 views
  • 0 likes
  • 2 in conversation