Hi Reeza,
here is the code that I did by modifying Tom's code and I ALMOST got what I wanted:
data filelist ;
infile 'dir C:\files\ /b *.txt' pipe truncover ;
input filename $256. ;
directory = 'C:\files\';
file_path=directory || filename; /*create the pathname */
name=substr(filename, 1, length(filename)-4); /*delete the .txt*/
file_number = compress(name,'','A'); /*extract the file number*/
unique_name = compress(name, file_number); /*extract the unique name*/
target_extension= '_all.txt';
target = directory || unique_name || target_extension;
run;
data _null_;
set filelist ;
infile source filevar=file_path end=eof ;
file target filevar=target ;
do while (not eof);
input;
put _infile_;
end;
run;
The only minor problem is that when I execute the code I get my 2 files (one concatenating f1 and f2, and one concatenating fh1 and fh2) but they are not in txt format, to open them I actually need to choose the program with which to open.
its probably related to :
target_extension= '_all.txt';
target = directory || unique_name || target_extension;
because when I looked at my SAS table "filelist" the target_extension is not fully concatenated to the other part, and I get something like:
C:\files\f
_all.txt
for the variable "target"
Thanks!
... View more