0

I am trying to load a large text file(report) as a single cell in SAS dataset, but because of multiple spaces and formatting the data is getting split into multiple cells.

Data l1.MD;
infile 'E:\Sasfile\f1.txt' truncover;
input text $char50. @;
run;

I have 50 such files to upload so keeping each file as a single cell is most important. What am I missing here?

Akshata T
  • 37
  • 5
  • 1
    Please post some examples of what your text files look like. – user667489 May 29 '15 at 20:35
  • You only want 1 variable with 1 observation? How big is the text file? You've made your variable only 50 characters long ... it will only be able to hold the first 50 characters. – DomPazz May 29 '15 at 21:05

1 Answers1

1
Data l1.MD;
  infile 'E:\Sasfile\f1.txt' recfm=f lrecl=32767 pad;
  input text $char32767.;
run;

That would do it. RECFM=F tells SAS to have fixed line lengths (ignoring line feeds) and the other options set the line length to the maximum for a single variable (lines can be longer, but one variable is limited to 32767 characters) and to fill it with blank spaces if it's too short.

You'd only end up with > 1 cell if your text file is longer than that. Note that the line feed and/or carriage return characters will be in this file, which may be good or may be bad. You can identify them with '0A'x and/or '0D'x (depending on your OS you may have one or both), and you can compress them with the 'c' option or translate them to a line separator of your preference.

Joe
  • 62,789
  • 6
  • 49
  • 67