BookmarkSubscribeRSS Feed
1162
Calcite | Level 5
I don't know why this isn't working. Is seems to be related to the delimiter. If I change the delimiter to something else, it works fine. I'd really like to get this working for tab delimited records. Am I missing something?

This works fine:
[pre]
data filelist;
infile cards dlm='#';
input Size :comma8. FileName :$50.;
cards;
123,345#C:\GFF\Denver File.txt
54,332,000#d:\FTR\Mars File.pdf
;
run;
[/pre]

This doesn't:
[pre]
data filelist;
infile cards dlm='09'X;
input Size :comma8. FileName :$50.;
cards;
123,345 C:\GFF\Denver File.txt
54,332,000 d:\FTR\Mars File.pdf
;
run;
[/pre]

This is the error I get:
[pre]
NOTE: Invalid data for Size in line 460 1-80.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
461 54332 d:\FTR\Mars File.pdf
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
Size=. FileName=54332 d:\FTR\Mars File.pdf _ERROR_=1 _N_=1
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.FILELIST has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
[/pre]
4 REPLIES 4
Doc_Duke
Rhodochrosite | Level 12
I think that you are SOL. CARDS; data were not intended to work with tabs. See the last sentence in
http://support.sas.com/kb/7/505.html
Put the data into an external file and then you can use tabs.
1162
Calcite | Level 5
Thanks for the reference. I had found that Note earlier and I concluded it was possible if the DLM='09'X was specified. Does that only work with certain operating systems?
CurtisMack
Fluorite | Level 6
You get a different problem if you take out the colons. It works fine except the format for SIZE is too short so the second value is truncated. If you increase the size of the informat to comma10, you get an invalid value for the first row. If you add a space after 123,345, that error goes away. I don't completely understand what is going on, but though I would share it with you.
ballardw
Super User
> Thanks for the reference. I had found that Note
> earlier and I concluded it was possible if the
> DLM='09'X was specified. Does that only work with
> certain operating systems?

A secondary issue that MIGHT affect this code is whether your settings in the editor are set to convert tabs to spaces on saving the file.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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