Let me edit this. Step 1 should be to read the data in one datastep for all the csv files and give a year variable from the filename.
https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/ta-p/223627
data import_all;
length filename txt_file_name $256;
retain txt_file_name;
infile "<path>\*.csv" eov=eov filename=filename truncover;
input@;
if _n_ eq 1 or eov then do;
txt_file_name = scan(filename, -1, "\");
eov=0;
end;
else input ...;
run;
Then with the one file, you can start processing the dataset, with the filename data as a column you can by group that, as an example:
proc means...;
by txt_file_name; ... run;
This will save you lots of writing datasets, macro code to process multiple datasets etc.
Sorry, probably didn't make it clear. I am just after a small sample of what you have - which details each of the steps, i.e. if there are multiple files, then a couple of line from a couple of files. The reason is the "first step" you talk about is the one I would drop - this is the step that creates xyz_2017, xyz_2018 etc. This would easier to work with as xyz with a column for year. So basically data in - at the start of the process - and examples of what you want out at the end.
... View more