Hi all I am trying to edit a macro which can import all csv files in a directory into SAS. However, it seems there is error if a csv file contains no data (i.e. only header row). Is there any way to ignore the error? Or to avoid importing those csv files? Thanks! %macro importfile(location);
filename _dir_ "%bquote(&location.)";
data _null_;
handle = dopen('_dir_');
if handle > 0 then do;
count = dnum(handle);
do i = 1 to count;
if find(dread(handle,i),'csv') > 0 then call execute(cat('Proc Import Out = Work.Testing', i, " DATAFILE= "', &location., dread(handle,i), '"DBMS = csv replace; run;'));
end;
end;
rc=dclose(handle);
run;
filename _dir_ clear;
%mend;
... View more