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?
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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.