DATA Step, Macro, Functions and more

Problem using CARDS statement with tab delimited data

Reply
Frequent Contributor
Posts: 95

Problem using CARDS statement with tab delimited data

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]
Trusted Advisor
Posts: 2,116

Re: Problem using CARDS statement with tab delimited data

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.
Frequent Contributor
Posts: 95

Re: Problem using CARDS statement with tab delimited data

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?
Frequent Contributor
Posts: 102

Re: Problem using CARDS statement with tab delimited data

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.
Super User
Posts: 11,343

Re: Problem using CARDS statement with tab delimited data

> 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.
Ask a Question
Discussion stats
  • 4 replies
  • 2067 views
  • 0 likes
  • 4 in conversation