There was a problem in my previous code, since it would not read all the data, find below a new sample that will read all the file into one SAS data set, one record = one obs. A second DATA Step will then put all values into one variable, but as already mentioned, there is a limit. Find also a DS2 program that does the same, except, you can have longer variables (as long as your in DS2).
data fileContents;
length extFilename _extFilename $ 1024;
length extLine $ 32767;
infile "c:\temp\*.txt" filename=_extFilename truncover end=last;
row + 1;
input
@1 extLine $32767.
;
extFilename = _extFilename;
run;
proc sort data=fileContents;
by extFilename row;
run;
data want;
set fileContents;
length fileContents $ 32767;
retain fileContents;
by extFilename;
if first.extFilename = 1 then do;
fileContents = ' ';
end;
fileContents = cats(fileContents, extLine);
if last.extFilename = 1 then do;
extLineLength = length(fileContents);
output;
end;
run;
proc ds2;
data want(overwrite=yes);
dcl varchar(10485760) fileContents;
retain fileContents;
method run();
dcl int extLineLength;
dcl varchar(1024) eFilename;
set fileContents;
by extFilename;
if first.extFilename = 1 then do;
fileContents = ' ';
end;
fileContents = cats(fileContents, extLine);
if last.extFilename = 1 then do;
/* do something here with the file contents */
extLineLength = length(fileContents);
end;
end;
enddata;
run;
quit;
Bruno
... View more