Hi Reeza, I have changed the method around to just read the csv file as is and rename the outputted SAS file. I nearly have it working but this is my issue. So my &name is being put in double quotations. I think this is the only issue to get this working. ERROR: ""File_2021_02_05"" is not a valid name. *This is the macro used to import csv files into SAS;
%macro process(DirectoryAndDataset= ,name=);
/*Firstly we read in the dataset called DatasetsInADirectory and keep one record each time depending on what iteration we are in*/
data DatasetsInADirectory_1;
set DatasetsInADirectory;
where DirectoryAndDataset="&DirectoryAndDataset" and name="&name";
run;
/*Program for loading the file we get*/
proc import datafile="&mig01.\Datasets\Files\ABC\2021\&DirectoryAndDataset..csv"
out="&name"(label='File 123')
dbms=csv
replace;
getnames=no;
*datarow=2;
GUESSINGROWS=MAX;
run;
%mend process;
*The above is the macro which is used, the below is the function which carries the process out for all N datasets;
/*Put a timer at begining and end to see how long processing takes for everything*/
data macro_call;
set DatasetsInADirectory;
*build macro call string;
str = catt('%nrstr(%process)(DirectoryAndDataset =', DirectoryAndDataset, ' ,name =', name,');');
*call macro;
call execute(str);
run;
... View more