- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
--------------------------