BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
data_null__
Jade | Level 19

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.

FriedEgg
SAS Employee

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;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 16 replies
  • 17276 views
  • 2 likes
  • 6 in conversation