Look up EOV INFILE statement option it is designed to detect the start of a new file in a concatenation. Much easier than comparing file names.
Thanks _null_, I had forgotten about that option.
/* create some dummy files */
data _null_;
do i=1 to 3;
call execute('filename file' || strip(i) || ' "/home/friedegg/file' || strip(i) || '.txt";');
call execute('data _null_;');
call execute(' file file' || strip(i) || ';');
call execute(' put "a b c d e";');
call execute(' put "f g h i j";');
call execute('run;');
end;
run;
filename indata '/home/mkastin/file*.txt';
data want;
length _file _filex $512;
infile indata eov=_firstrec_;
input (blah1-blah5) (:$1.);
if _n_ or _firstrec_ then delete; /* _firstrec_ will =1 for all files first record except the first */
run;
/* remove this junk */
data _null_;
do i=1 to 3;
call execute('x "rm -f /home/friedegg/file' || strip(i) || '.txt";');
end;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.