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.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.