Hi SAS Experts,
I got the following macro to import files and noticed that when I add one or more files that some columns are not properly imported anymore. It is really weird. and I cant explain it.
%macro MultImp(dir=,out=); %let rc=%str(%'dir %")&dir.%str(\%" /A-D/B/ON%'); filename myfiles pipe %unquote(&rc); data importedfilesoverview; length fname $256.; infile myfiles truncover; input myfiles $100.; fname=quote(upcase(cats("&dir",'\',myfiles))); first2chars=quote(substr(myfiles,1,2)); /* country*/ next5chars=quote(substr(myfiles,7,1)); /* year*/ out="&out"; drop myfiles; call execute(' proc import dbms=xls out= _temp datafile= '||fname||'; getnames=no; datarow=10; run; /* new: */ proc sql; create table _temp2 as select '||first2chars||' as first2chars, '||next5chars||' as next5chars, * from _temp; run; proc append data=_temp2 base='||out||' force; run; proc delete data=_temp _temp2; run; '); run; filename myfiles clear; %mend; %MultImp(dir=R:\myfiles\,out=Importcont_Import);
... View more