05-10-2014 08:41 AM
I have a macro that imports data for example:
%macro importdata(datafile) ;
<IMPORT DATA PROCEDURES...>
I have 10 files with the same structure I would then run the macro on.
In the end I would like to Append the files together as part of the macro.
Right now i am writing an additional datastep and manually scripting the dataset names from each macro output, i'm sure there is a better way.
Thank you for the help.
05-10-2014 09:42 AM
Yes, I was thinking of creating a blank template as a 'Master' table to append in the macro, and as I run each file import it will append to the master, but i'd have to be careful not to run the same file twice, or if there is an error in one of the file imports i'd probably have to rerun all of the imports again.
Unfortunately the file names are not sequentially structured to use Name: or name1-name10;
05-12-2014 11:11 AM
You don't mention the format of the data source files or how you are importing them. If using PROC IMPORT you may end up with different variable types for the same variable name which is going to cause problems as in failure to either Append or Set properly.
If you use filerefs instead of literal names then you add on to data_null_'s comment about creating dataset names in an easier fashion:
filename inset1 "<path and file for first data set>";
filename inset2 "<path and file for 2nd data set>";
and so on.
Or could be generated by reading a directory if things are clean enough.