BookmarkSubscribeRSS Feed
philjones820
Fluorite | Level 6

Hello, I have a folder of 14 text delimited files that I need to import into SAS. Is it possible to import them all in at the same time rather than one at a time and is there any sample code and macro that anyone could recommend? Is there possibly a way to loop through each file from 1 to 14 and pull all 14 of the files in simultaneously?

1 REPLY 1
mkeintz
PROC Star

Are the files identically formatted?  That would make it a far simpler programming structure to process all of them in a single data step.

 

If they are all the same format then you could list all 14 filenames in a single FILENAME statement.  The list would be a comma-separated list of file names, all wrapped in parentheses:

 

filename inall ('c:\temp\t1.txt','c:\temp\t2.txt');
data want;
  infile inall;
  input a b c .... ;
run;

BTW, I don't know what "text delimited" means. Comma delimited, TAB delimited yes - but text delimited?   I suppose you mean you have field delimiters in the 14 files.  If so, then modify the INFILE statement accordingly - using whatever options you would use for any single file (again, assuming all files have the same delimiter).

 

There is no doubt a limit on the length of the delimited file list, but I assume SAS will tolerate a list of 14 files.  

 

I put the INPUT statement there as a placeholder for whatever variables you will be sasifying.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

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
  • 1 reply
  • 796 views
  • 0 likes
  • 2 in conversation